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.

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
  • 2 replies
  • 1182 views
  • 2 likes
  • 3 in conversation