Categories‎ > ‎

Stored Processes

These macro programs are essentially long, complex, stored processes that enable to the user to efficiently re-use programs without copying-and-pasting the code, which would cause issues when one version is changed but not another. These macro programs are more typical of what is found online and in-house.


Check logs for issues. See the CheckLog page for more information.


Compress a data set using either the DATA step or PROC DATASETS.


Copy data from one library to another, with various additional options.


Copy a file using an operating system command.


Generate a data set that contains a listing of the files in a directory, optionally including subdirectories and filtering for a specific extension.


Check if a table exists and then delete it. Avoids generating an issue in the log if the data set is already gone.


Output an email with various options, including attachments.


Put SAS to sleep for a specified period of time. Useful when scheduled tasks are not available.


Remove labels from a data set.


Output a new variable that contains the names of numbers instead of the number. For example, if the source variable contains 1000, the output variable would be "One thousand".


Generate a random set of data based on one of two processing options. Type 2 is generally faster for large data sets. The RAND function is used to select observations.


Rename variables in a data set based on a mapping data set that contains source and target names.


Change the order of variables in a data set based on a list or an example data set.


Search SAS code for a term or a regular expression. Useful when SAS code is not indexed by the operating system or to generate a data set that contains a list of code for various purposes (e.g. batch code revisions).


Select records that match a specific statistic (usually MIN or MAX of a variable). Useful for processing some duplicate observations; for example, to select the most recent date for a set of records for a person (MAX).


Download macros from this site!


Put SAS to sleep to time tea steeping. Useful when the user can't install software.


Export a data set as a text file. Uses PROC EXPORT and tab as a delimiter.


Creates an ID for a text field that will be the same whenever it's run. Useful when an ID is needed (especially for categorical variables), the source does not have an ID, and the ID needs to be the same each time it is generated. The process converts each character into its binary representation, converts the binary number to decimal, then sums up each decimal representation of the characters. Note that this process is therefore case sensitive, and two IDs will be generated for slightly different values (e.g., "Commercial" and "commercial" will have different IDs).


Generates a series of views based on a library, output to a new library (thus, "ViewLib"). This can be useful when renaming data sets or variables in a library without changing the source library.


Import a file without delimiting it (i.e., with only one column). Useful when importing a file that has only one "thing" in it, for example, the SAS log, which consists of only text.