Hello,
I am trying to create a drop statment using a list of variables in a file eg
"a b c" to drop from a table with EG: "a b c d e f" output should only have var "d e f". Any help is appreciated.
//DRPFLE DD DISP=SHR,DSN=SAS.OUTPUT.DROPLIST
//TBLFLE DD DISP=SHR,DSN=SAS.OUTPUT.TABLE
DATA DRPVAR(KEEP=VARNAME);
INFILE THEFILE END=EOF MISSOVER ;
INPUT @1 VARNAME $CHAR8.
;
DATA DRPSTF (KEEP=VARLIST);
FORMAT VARLIST $32767.;
SET DRPVAR END=EOF;
VARLIST=CATS(' ',VARLIST,VARNAME);
DATA DRPIT;
SET STUFF DRPSTF (DROP=&VARLIST);
PROC PRINT;
If your data set DRPVAR contains names of variables to drop (not stated anywhere) easiest might be a macro variable made this way:
Proc sql noprint; select name into :varlist separated by ' ' from DRPVAR ; quit;
Then use
DATA DRPIT; SET STUFF DRPSTF (DROP=&VARLIST); run;
If your data set DRPVAR contains names of variables to drop (not stated anywhere) easiest might be a macro variable made this way:
Proc sql noprint; select name into :varlist separated by ' ' from DRPVAR ; quit;
Then use
DATA DRPIT; SET STUFF DRPSTF (DROP=&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.
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.
Ready to level-up your skills? Choose your own adventure.