Hello,
I have a dataset which has many variables. I don't need those variables which has 'f' in the last position of the name. For example, the names of those variables are like wagef, levelf, posf.
Thanks for help.
Combination of Patrick and LinLin.
proc sql noprint;
select name into : names separated by ' '
from dictionary.columns
where libname='WORK' and memname='HAVE' and upcase(name) like '%F' ;
quit;
Ksharp
data have;
input aaf bbbf ccc;
cards;
1 2 4
2 3 8
;
proc sql noprint;
select name into : names separated by ' '
from dictionary.columns
where libname='WORK' and memname='HAVE' and lowcase(substr(name,length(name),1))='f';
quit;
data want;
set have (drop=&names);
run;
proc print;run;
Obs ccc
1 4
2 8
Linlin
data have;
wagef=1;
wage=1;
wagefn=1;
xageF=1;
run;
%let dellist=;
proc sql;
select name into :dellist separated by ','
from dictionary.columns
where libname='WORK' and memname='HAVE' and upcase(name) like '%F'
;
%macro _del;
%if %bquote(&dellist) ne %bquote() %then
%do;
alter table work.have
drop &dellist
;
%end;
%mend;
%_del
quit;
proc contents data=work.have;
quit;
Combination of Patrick and LinLin.
proc sql noprint;
select name into : names separated by ' '
from dictionary.columns
where libname='WORK' and memname='HAVE' and upcase(name) like '%F' ;
quit;
Ksharp
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.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.