AFHood Group Blog The thoughtless yammerings of marketing junkies..

17Mar/092

SAS Temporary Variables – Just drop them..

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 = <some code here>;

new_variable = <some more code here.. probably something to do with the _temp_var>;

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.

Comments (2) Trackbacks (0)
  1. Very useful thanks for the tip!

  2. Thanks!


Leave a comment

No trackbacks yet.