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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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