-
Notifications
You must be signed in to change notification settings - Fork 9
Macro Variable Manipulation
Chris Swenson edited this page Nov 14, 2020
·
3 revisions
Macro programs that create macro variables should do the following:
- Delete similar macro variables that already exist to avoid conflicts.
- Create the specified macro variables in the specified manner.
- Report the macro variables created in a single list using SASHELP.VMACRO.
- Allow for filtering of the input data (if possible).
The following macro programs create macro variables for use later in the code, except for DelVars, which deletes macro variables.
-
ColumnVars
- Set macro variables for tables from SASHELP.VColumn, one variable per column.
- Output: Multiple macro variables, one for each column.
-
DelVars
- Delete all user macro variables. This is best used to clear out macro variables before moving on to another process in order to avoid conflicting or mistaken values. A list of macro variables can be excluded from deletion.
-
IntoList
- Create a macro variable that is a list of values from a column in a data set. Optionally define the delimiter and filter the input data set.
- Output: Single macro variable consisting of a list
-
ObsMac
- Set observations in a data set to macro variables, using a specified prefix and the observation number to create the macro variable name. Optionally filter the input data set.
- Output: 1-to-many macro variables with appended numbers
-
SetVars
- Create one or more macro variables from the variable names in a data set. The generated macro variable can either be a list within one macro variable or multiple macro variables named with the specified prefix and appended observation number.
- Output:
- type=MULTI: 1-to-many macro variables with appended numbers
- type=LIST: Single macro variable consisting of a list
-
TableVars
- Generate macro variables for tables identified from SASHELP.VTABLE, naming the variables using the specified prefix and the observation number of the table. Useful when processing multiple data sets. Similar to ObsMac, but with a static source table.
- Output: 1-to-many macro variables with appended numbers
-
VarMac
- Create macro variables from two columns, where one column names the macro variable and another supplies the value. Optionally filter the input data set.
- Output: 1-to-many macro variables
Notes
Please see the Macro Variable Manipulation Examples page for examples on how to use these programs.
Please set the Macro Variable Manipulation Demonstration page for a demonstration using these programs.
Disclaimer: The SAS macros on this site are provided "as-is". The user is responsible for testing the code on their platform. The user agrees that the author will not, under any circumstances, be held accountable for any damages of any type that result from using these macros. Please review the license provided with the programs.
- Home
- Categories
- Documentation
- Send Feedback [External]
- Christopher A. Swenson
- About & Contact [External]
- Professional Samples [External]
- Resume [External]
- References [External]
- Blog [External]