Completely new to SAS here.
I have a data set with a huge amount of variables. I would like to extract all the variables that for example contains the string "GRP" within its name, and create a new data set from these variables.
EDIT: I do not know any of the variable names, as the data set is huge.
You can first store the variables you're interested into a macro variable and then use them in a keep list. Using data set name work.have as an example to create work.want:
/* note the use of use UPPERCASE */
proc sql noprint;
select name into :varlist separated by ' '
from dictionary.columns
where libname='WORK'
and memname='HAVE'
and upper(name) contains 'GRP'
;
quit;
/* keep only required variables */
data want;
set have(keep=&varlist);
run;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments