Five Easy (To Use) Macros

Consider increasing your SAS vocabulary by five words: %DIR, %MAKEFMT, %TRANSPO, %ARRAY and %DO_OVER. Macro definitions are in the appendix. %DIR creates a SAS data set with the list of files in a directory. %MAKEFMT creates a format from a data set. %TRANSPO changes data from a series of observations to one observation per by-group with arrays of variables, preserving variable attributes. Finally, %DO_OVER, with the support of its companion %ARRAY, generates repeated program code. %DO_OVER loops over a list of values, substituting them wherever you put a “?” in your code phrase. For example, RENAME %DO_OVER(values=A B C, phrase= ?=?suf); generates the statement RENAME A=Asuf B=Bsuf C=Csuf; The code phrase can consist of many statements or an external macro, and multiple arrays can be defined and looped-over in parallel. No other macros have had a greater impact than these two, appearing in over 40% of the author’s statistical programs.

conference: 
Author: 
Paper Type: 
Paper

User login

Syndicate

Syndicate content
Drupal 6 Appliance - Powered by TurnKey Linux