Check the current SAS log, an external log, or a directory of logs for issues, including error, warning, invalid, and uninitialized messages as well as a list of phrases usually associated with issues. See CheckLog sidebar for full documentation: http://sas.cswenson.com/checklog/
Compare the contents to two data sets to determine differences. The data sets should be similar; otherwise, many differences will arise. UPDATE: Added the LIB= argument to specify the temporary and output library (defaulted to WORK).
Check for duplicates within a data set with multiple options, including an option to split the distinct records from the duplicate records, suggest which variable(s) may be involved in duplication (requires the DupVar macro), and the ability to flag the output as expected.
Split the library and table into macro variables for later reference. Useful when a specified argument needs to be split to output the data somewhere other than the source (e.g., when the source is read-only).
Use a Windows message box with options for the message, title, buttons, icon, and the type of execution (macro or DATA step). This macro requires that the Windows API code be stored in a permanent location (e.g., the USER library). Open the macro to view the API code.
Open a specified table, the last table, or the table copied to the clipboard. Uses the API in the MessageBox macro or a %WINDOW statement. Please review the code and decide which method to use. The macro is very efficient when a library has many tables.
Rename variables in a data set based on mapping specified in a data set called RenameVars, with the option to filter the RenameVars data set. This is useful when renaming multiple data sets using a common mapping document.
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.
Download and include the macros on this site! Include specific macros or all macros, and optionally force the source code to be printed (single macros only). Additionally, save the macros to an autocall library or store them in a compiled macro catalog (06/08/2011). Added better processing in the UNIX environment (08/08/2011).
Sort and compare data sets using PROC COMPARE, which requires sorted data. Eliminates repetitive coding. Optionally excludes specific variables. The macro also identifies and splits out records that exist in one or the other data set for examination. This macro is useful to verify that two data sets are identical. UPDATE: Added LIB= argument to specify the temporary file and output library (defaulted to WORK).
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.
Convert a (completely) text value to an ID that will be the same for the specific text each time it is run. This process can be valuable for adding an ID to a text value when no ID exists, and the same ID is needed for the same text values and each time it is run.Note that the macro is case sensitive, so if upper- and lower-case text need to have the same ID, the input data set should be modified first. The macro converts the text to its binary representation then sums up the numeric value for the entire field.Warning: If the input value contains numbers, it is possible the output may not be distinct by the input, since the sum of some numbers could be the same. This process is best for converting categories (i.e., alphabetic values only) to an ID.
Transpose all columns in a data set, based on by variable(s) and an ID variable (for PROC TRANSPOSE), and re-merge all the columns back into one data set. The names of the columns are set to the original name as a prefix, with the ID added at the end, and an optional suffix.
Write "issues" (error/warning) to the log when a data set contains records.
Jul 20, 2011, 7:56 AM
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.