because arrays are bit messy and it is not easy to debug them:
First thing to understand is, that result of ****
/ppp secret print as-value where name="username"
is actually an array of arrays. That is caused by the fact that the code can return multiple rows if there are multiple entries with same name. Obviously, due to that, there is no key “profile” in the returned value. This key is present only in sub-arrays.
So if you are 100% certain you will always have just one user selected (i.e. you are sure there will be never more users with same name), you can use:
:put ([/ppp secret print as-value where name="username"]->0->"profile")
Otherwise, you can simply foreach all returned users:
:foreach aa in=([/ppp secret print as-value where name="username"]) do={:put ($aa->"profile")}