Hello,
I have a dataset with over 1000 variables, I want to scan this entire dataset and create a subset of data that contains all variables with the suffix "_MEAN" Any insight would help. Thanks!
cat_mean cat_toy dog_mean dog_toy bird_mean bird_toy
7.00 2 0.987 56 1.345 67
What I want:
cat_mean dog_mean bird_mean
7.00 0.987 1.345
One way
data have;
input cat_mean cat_toy dog_mean dog_toy bird_mean bird_toy;
datalines;
7.00 2 0.987 56 1.345 67
;
proc sql noprint;
select name into :vars separated by ' '
from dictionary.columns
where upcase(libname)=upcase('work')
and upcase(memname)=upcase('have')
and upcase(name) like "%_MEAN";
quit;
data want;
set have;
keep &vars.;
run;
One way
data have;
input cat_mean cat_toy dog_mean dog_toy bird_mean bird_toy;
datalines;
7.00 2 0.987 56 1.345 67
;
proc sql noprint;
select name into :vars separated by ' '
from dictionary.columns
where upcase(libname)=upcase('work')
and upcase(memname)=upcase('have')
and upcase(name) like "%_MEAN";
quit;
data want;
set have;
keep &vars.;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: