is there any difference in the drop, keep, (drop=), and (keep=) function?
Yes.
DROP/KEEP are STATEMENTS usually only valid in a SAS data step.
DROP=/KEEP= are data set OPTIONS. They can be used almost anywhere you reference a SAS data set including in a SQL step.
They act at different points of time, for example a KEEP statement in the data step will only keep variables but they're available for calculations. If you use DROP = on a data set that's being read for example that data is not read into the step and cannot be used in calculations.
data want1 (drop=weight) want2 (drop=height); *variables are dropped for output data sets;
set sashelp.class (drop=age); *age is dropped before the data is read in;
new_name = catt(name, ' Smith');
drop name;*name is dropped for all data sets but is available for calculations;
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 25. 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.