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

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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