BookmarkSubscribeRSS Feed
rinugour
Fluorite | Level 6

How can you limit the variables written to output dataset in DATA STEP?

3 REPLIES 3
Oligolas
Barite | Level 11

Hi,

 

you can use the DROP or KEEP statements

________________________

- Cheers -

Amir
PROC Star

Hi,

 

As well as the keep and drop statements answer already given by @Oligolas there are also keep= and drop= data set options.

 

For syntax details and an example, see the documentation:

 

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000131144.htm

 

 

Regards,

Amir.

anjita
Fluorite | Level 6

Both DROP and KEEP can be used to limit the variables in the dataset.

  • The DROP=option tells SAS which variables you want to  If you place the DROP= option on the SET statement, SAS drops the specified variables when it reads the input data set and if you place the DROP= option on the DATA statement, SAS drops the specified variables when it writes to the output data set.
  • The KEEP=option tells SAS which variables you want to  If you place the KEEP= option on the SET statement, SAS keeps the listed variables when it reads the input data set. On the other hand, if you place the KEEP= option on the DATA statement, SAS keeps the specified variables when it writes to the output data set. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 3 replies
  • 1621 views
  • 0 likes
  • 4 in conversation