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..";
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.