BookmarkSubscribeRSS Feed
scb
Obsidian | Level 7 scb
Obsidian | Level 7

The below macro variable a will get a,b,c,d; may I know how to get a.a, a.b, a.c, a.d?


data test;
infile datalines dsd;
input a1 $ a2 $ a3 $ a4 $;
cards;
a,b,c,d
;
run;


data test;
set test;
call symputx("a",catx(",",of a: ));
run;
%put &a;

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26
data test;
  infile datalines dsd;
  input a1 $ a2 $ a3 $ a4 $;
  call symputx("a",cats("a.",catx(",a.",of a:)));  
cards;
a,b,c,d
;
run;
%put &a.;

The question really is why you would be wanting to do that in the first place.

ballardw
Super User

@scb wrote:

The below macro variable a will get a,b,c,d; may I know how to get a.a, a.b, a.c, a.d?


data test;
infile datalines dsd;
input a1 $ a2 $ a3 $ a4 $;
cards;
a,b,c,d
;
run;


data test;
set test;
call symputx("a",catx(",",of a: ));
run;
%put &a;


You really do not want to do that as a.a is  not a valid SAS variable name in general and the . would have SAS report some sort of SCL error. You could make date name literals but you would have to reference the resulting variable as 'a.a'n every time you use it.

So explain why you think you want a.a , a.b etc.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 798 views
  • 2 likes
  • 3 in conversation