BookmarkSubscribeRSS Feed
clqa
Calcite | Level 5

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

2 REPLIES 2
Cynthia_sas
SAS Super FREQ
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;

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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