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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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: