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.

CheckLog

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

CompressDS

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

CopyData

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

CopyFile

Copy a file using an operating system command.

DirList

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

DropTable

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

Email

Output an email with various options, including attachments.

NapTime

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

NoLabel

Remove labels from a data set.

NumberName

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".

RandomSet

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.

RenameVars

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

Reorder

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

SearchCode

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).

SelectStat

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).

SiteMacros

Download macros from this site!

TeaTimer

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

TextExport

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

TextID

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).

ViewLib

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.

XDLM

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.