Previous Page | Next Page

Macro Variables

Macro Variables Defined by the Macro Processor

When you invoke SAS, the macro processor creates automatic macro variables that supply information related to the SAS session. Automatic variables are global except SYSPBUFF, which is local.

To use an automatic macro variable, reference it with an ampersand followed by the macro variable name (for example, &SYSJOBID). This FOOTNOTE statement contains references to the automatic macro variables SYSDAY and SYSDATE9:

footnote "Report for &sysday, &sysdate9";

If the current SAS session is invoked on December 17, 2007, macro variable resolution causes SAS to receive this statement:

FOOTNOTE "Report for Monday, 17DEC2007";

Automatic macro variables are often useful in conditional logic such as a %IF statement with actions determined by the value that is returned. For more information, see %IF-%THEN/%ELSE Statement.

You can assign values to automatic macro variables that have read and write status. However, you cannot assign a value to an automatic macro variable that has read-only status. The following table lists the automatic macro variables that are created by the SAS macro processor and their read/write status.

Use %PUT _AUTOMATIC_ to view all available automatic macro variables.

There are also system-specific macro variables that are created only on a particular platform. These are documented in the host companion, and common ones are listed in Writing Efficient and Portable Macros. Other SAS software products also provide macro variables, which are described in the documentation for the product that uses them. Neither of these types of macro variables are considered automatic macro variables.

Automatic Macro Variables by Category
Status Variable Contains
Read and Write SYSBUFFR unmatched text from %INPUT

SYSCC the current condition code that SAS returns to your operating environment (the operating environment condition code)

SYSCMD last unrecognized command from the command line of a macro window

SYSDEVIC name of current graphics device

SYSDMG return code that reflects an action taken on a damaged data set

SYSDSN name of most recent SAS data set in two fields

SYSFILRC return code set by the FILENAME statement

SYSLAST name of most recent SAS data set in one field

SYSLCKRC return code set by the LOCK statement

SYSLIBRC return code set by the LIBNAME statement

SYSLOGAPPLNAME value of the LOGAPPLNAME option

SYSMSG message for display in macro window

SYSPARM value specified with the SYSPARM= system option

SYSPBUFF text of macro parameter values

SYSRC various system-related return codes
read-only SYSCHARWIDTH the character width value

SYSDATE the character value representing the date a SAS job or session began executing (two-digit year)

SYSDATE9 the character value representing the date a SAS job or session began executing (four-digit year)

SYSDAY day of week SAS job or session began executing

SYSENCODING name of the SAS session encoding

SYSENV foreground or background indicator

SYSERR return code set by SAS procedures and the DATA step

SYSERRORTEXT text of the last error message formatted for display on the SAS log

SYSHOSTNAME host name of the operating environment

SYSINDEX number of macros that have begun execution during this session

SYSINFO return code information

SYSJOBID name of current batch job or user ID (varies by host environment)

SYSMACRONAME name of current executing macro

SYSMENV current macro execution environment

SYSNCPU the current number of processors that SAS might use in computation

SYSODSPATH the value of the PATH variable in the Output Delivery System (ODS).

SYSPROCESSID the process ID of the current SAS process

SYSPROCESSNAME the process name of the current SAS process

SYSPROCNAME name of current procedure being processed

SYSSCP the abbreviation of an operating system

SYSSCPL the name of an operating system

SYSSITE the number assigned to your site

SYSSTARTID the ID generated from the last STARTSAS statement

SYSSTARTNAME the process name generated from the last STARTSAS statement

SYSTCPIPHOSTNAME host names of the local and remote operating environments when multiple TCP/IP stacks are supported

SYSTIME the character value of the time a SAS job or session began executing

SYSUSERID the user ID or login of the current SAS process

SYSVER release or version number of SAS software executing

SYSVLONG release number and maintenance level of SAS software with a 2-digit year

SYSVLONG4 release number and maintenance level of SAS software with a 4-digit year

SYSWARNINGTEXT text of the last warning message formatted for display on the SAS log.

Previous Page | Next Page | Top of Page