Explain more about how the data is structured. Why do you have dates stored in the NAME of the variable. It is best to store data in the VALUE of a variable instead.
If you have a variable (or set of variables) that uniquely identify the observations in your dataset perhaps you should first transpose the data.
proc transpose data=have out=tall;
by id;
run;
Then you can select the observations from the TALL dataset what came from variables that had a particular pattern to their names.
data want;
set tall;
where _name_ like '%^_20230612' escape '^' ;
run;
If you really want to perpetuate the problem of having dates in variable names you could build a list of variable names into a macro variable
proc sql noprint;
select nliteral(name) into :varlist separated by ' '
from dictionary.columns
where libname='WORK' and memname='HAVE'
and name like '%^_20230612' escape '^'
;
quit;
and use the macro variable to generate part of the code to select the variables of interest.
data want;
set have;
keep id &varlist;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.