Hello,
I wrote a program to assign a new column 'Class' corresponding to different dataset names. I found out the class is shown in '&&Y&i.', and not the individual dataset name. I have Please let me know how to fix it. Thank you.
%let Y1=ulung; %let Y2=uheme; %let Y3=ucancer; %let Y4=utransplant; %let Y5=ugm; %macro assign; %do i = 1 %to 5; data &&Y&i.. (keep=Underlying_Cond class); set &&Y&i.; Underlying_Cond=strip(Upcase(Underlying_Conditions)); Class='&&Y&i..'; run; %end; %mend; %assign;
Text that contains macro references should be enclosed in double-quotes, not single-quotes.
Text that contains macro references should be enclosed in double-quotes, not single-quotes.
Perhaps you are missing double quotes?
Class="&Y&i..";
The reason the value is literally
&&Y&i..
is because that is that you asked it to do.
If you want string values to be evaluated by the macro processor use double quote characters instead of single quote characters.
Class="&&Y&i..";
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.