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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1900 views
  • 0 likes
  • 2 in conversation