Thursday, April 18, 2013

SAS - Temporary variables

Lifted this from http://www.afhood.com/blog/?tag=temporary-variables

This is a great practice that we picked up from the guys over on SAS-L. It is a way to create temporary variables in datasteps that are dropped before being written to the output dataset.
data output_dataset (drop=_:);
set input_dataset;
_temp_var = ;
new_variable = ;
run;
The variables beginning with the underscore ("_") will be dropped before being written to the output dataset. It doesn't matter if there is one temp variable or 1000. As long as they begin with an underscore, they will not make it to the output dataset.  If you use this drop statement without creating any temporary variables you will get a warning.

Just the information I was looking for this morning! Thanks.


No comments:

Post a Comment