Hi, Cynthia,
Thanks for your posting, I learned much from it. However, I am unable to follow this step:
"break up the string: &&out &previtem &&y".
Is there any particular reason to break the string in this way? I carefully read your explanation about the forward scan rule and the rescan rule and I think neither the forward scan rule and the rescan rule implies it. For example, let's consider the following code:
%let d = one;
%put &&&&d;
For this case, how should I perform the step: break up the string? There seem no clear boundaries as the first example we can break the string up.
The below is my own understanding, please correct me if it is wrong: It seems that at one time, from left to right, SAS tries to resolve all the macro variables indicated by & simultaneously, so for the first example &&out&previtem&&y, in the first attempt (scan), SAS resolves "&&", "&previtem", and "&&" to "&", "1" and "&" respectively, while keeping "out" and "y" unchanged, producing
"&out1&y",
then starts the second scan. At this time, there are two and only two macro variables &out1 and &y, and will be resolved to "ay1". In
"ay1", no macro variable is detected, so the resolve procedure ends.
In my example "&&&&d", in the first scan, SAS resolves "&&" and "&&" to "&" and "&", leaving "&&d" for the second scan, which resolves to "&d", and finally "one".
Thanks again for your time.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.