Categories‎ > ‎


The following macro programs act as functions, and should only be used where functions can be used:


Calculates age based on a standard, SAS-recommended formula. See this article for more details.


Use the DATEPART function, which outputs only the date from a datetime variable, without generating an issue in the log when missing values are encountered. The macro has options to set the output variable name and format, to create a label with information about the source column, and to output a final comma if requested.


A function for converting data from numeric to character, character to numeric, date/datetime to character, date to datetime, or datetime to date.


Use the COUNTW function in SAS 9.2+ and an alternative in prior versions. Limitation: The macro only uses one delimter at a time. This is useful for dynamic programs to maintain backward compatibility.


The following macro programs, listed under Code Helpers, are similar to the above macros in that they output a value, like a function. However, they operate in the macro language itself, not within a DATA or PROC step.
For more on these macro programs, see Code Helpers.