BookmarkSubscribeRSS Feed
sasuser1000
Calcite | Level 5
I usually use this in order to create a varlist

%let varlist=var1 var2 var3;

I call the varlist by using &varlist

I have a dataset with 4000 variables that I would like to keep into a varlist as well without entering them one by one in the %let statement

Any idea on how to do this?
3 REPLIES 3
art297
Opal | Level 21
Yes you can, but why? What are you trying to do as variables are automatically kept unless you explicitly drop them?

You can always use proc sql on dictionary.columns to automatically create a macro variable that contains the kind of list you describe.

Art
sasuser1000
Calcite | Level 5
Hi Art297,

do you mean doing this?

proc sql;
select a.* into:varlist2
from class as a;
quit;
art297
Opal | Level 21
No. Assuming by class you meant sashelp.class, then what I meant was:
[pre]
proc sql noprint;
select name
into :varlist2 separated by " "
from dictionary.columns
where libname eq "SASHELP" and
memname="CLASS"
;
quit;
[/pre]

Art

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