Just to be clear, what do you want the value of Name to be in the two code snippets?
Are the macro variables fixed or can I change them a bit? Seems easier not having the 1 in all of them
Please try the below code
Data ex1;
Name="&&&state&I.&&i" ;
Run;
Change your code into:
%let I=1;
%let state1=ap;
%let ap1=India;
%let India1=Asia;
/*First - I want to resolve ap1 macro variable I wrote like below. */
Data ex1;
Name="&&&state&I&&I." ;
Run;
/*Second*/
I want to resolve India1 macro variable I wrote like below.
Data ex2;
Name="&&&&&&state&I&&i.";
Run;
Remember - sas resolves macros step by step. Each pair of && become a single &, thus:
1) &&&&&&state&I&&i
2) &&&state1&i
3) &&ap1
4) India
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.