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;
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 save with the early bird rate—just $795!
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.