You can do this in a different way using the experimental (as of 13.1) Tree
structure and related functions. This replaces the somewhat tricky FixedPoint
or ReplaceRepeated
constructions with an entirely new form of awkwardness.
First, let's name our nested association:
assoc =
<|"fff" -> <|
"2001" -> <|5040.` -> {"S20010037", "S20010038",
"S20010039", "S20010040", "S20010041", "S20010042"}|>,
"2005" -> <|4350.` -> {"S20050448", "S20050449"},
3450.` -> {"S20050998", "S20050999"}|>|>|>;
Then we can turn it into a Tree
object, though it requires a surprising and quasi-documented circumlocution:
tree = ExpressionTree[assoc, "Association"];
From there we can find the "position" of each leaf, meaning the association keys needed to reach it:
pos = TreePosition[tree, _, "Leaves"]
(*
{{Key[fff],Key[2001],Key[5040.]},
{Key[fff],Key[2005],Key[4350.]},
{Key[fff],Key[2005],Key[3450.]}}
*)
I think we need the Key
wrappers for our next step, so we'll get rid of them at the end:
KeyMap[ReplaceAll[Key->Identity],
AssociationMap[
TreeExtract[tree,#,TreeData]&,
pos]]
(*
<|
{fff,2001,5040.}->{S20010037,S20010038,S20010039,S20010040,S20010041,S20010042},
{fff,2005,4350.}->{S20050448,S20050449},
{fff,2005,3450.}->{S20050998,S20050999}
|>
*)