Help using Base SAS procedures

Option to only keep variables referenced in program

Reply
Occasional Contributor
Posts: 9

Option to only keep variables referenced in program

Is there an option to only keep variables referenced in a program?  I would like to shrink a large dataset but would prefer not to have to identify 50-80 variables everytime I start a new analysis. 

Super User
Posts: 5,081

Re: Option to only keep variables referenced in program

There isn't such an option.  However, you might be able to lessen the workload.  Instead of naming 50 to 80 variables toward the end of the program, you might be able to keep just 20 or 30 variables at the beginning of the program.  Those would be kept, along with all variables that are calculated by executing the program.

 

Without more specifics about what the program does, it's difficult to give more specific suggestions.

 

If the variables you are keeping have recognizable patterns to their variable names, additional possibilities exist.  For example, it's easy to keep all variables where the variable name begins with "var_".

Occasional Contributor
Posts: 9

Re: Option to only keep variables referenced in program

Thanks. What is the syntax for keeping all var that start with "var_"?

Super User
Posts: 17,807

Re: Option to only keep variables referenced in program

[ Edited ]

Use the colon operator to specify a prefix.
Keep var_:;

Use a list for variables that are sequentially labelled.
Keep var1-var100;

Use -- to keep variables that are side by side. All variables in between the two variables listed are kept.

keep var1--middle_var;

 

The documentation details it better than I can, as usual:

http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#p0wphcpsfgx6o7n1sjtq...

 

Super User
Posts: 9,676

Re: Option to only keep variables referenced in program

Create an VIEW ?
Ask a Question
Discussion stats
  • 4 replies
  • 294 views
  • 1 like
  • 4 in conversation