BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Text that contains macro references should be enclosed in double-quotes, not single-quotes.

--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Text that contains macro references should be enclosed in double-quotes, not single-quotes.

--
Paige Miller
novinosrin
Tourmaline | Level 20

Perhaps you are missing double quotes?

Class="&Y&i..";

 

 

Tom
Super User Tom
Super User

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..";

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 829 views
  • 0 likes
  • 4 in conversation