BookmarkSubscribeRSS Feed
clqa
Calcite | Level 5

is there any difference in the drop, keep, (drop=), and (keep=) function?

2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
We cover the use of DROP and KEEP statements versus DROP= and KEEP= options in our Programming 1 and Programming 2 classes. For a discussion of the differences, you might want to look in the documentation.

Cynthia
Reeza
Super User

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;
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1735 views
  • 0 likes
  • 3 in conversation