BookmarkSubscribeRSS Feed
bismilla
Calcite | Level 5

i want a create a macro variable by taking all the values of the variable into the macro variable

 

ex;-

data ds1;

set sashelp.class;

run;

 

2 REPLIES 2
andreas_lds
Jade | Level 19

@bismilla wrote:

i want a create a macro variable by taking all the values of the variable into the macro variable

 

ex;-

data ds1;

set sashelp.class;

run;

 


Do want all values of one variable stored in a macro variable or do you want all values of all variables in one macro-variable?

As said by @Kurt_Bremser, storing data in macro variables is almost always not necessary and you will be forced to write more code, than necessary.

 

This is, by the way, one of the very, very rare cases, in which using proc sql is justified:

proc sql noprint;
  select Name 
    into :NameList separated by ' '
    from sashelp.class
  ;
quit;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 623 views
  • 0 likes
  • 3 in conversation