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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.