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 16, 2011, macro variable resolution causes SAS to receive this statement:
FOOTNOTE "Report for Friday, 16DEC2011";
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 and /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
SYSADDRBITS
The number of bits of an address
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
SYSENDIAN
An indication of the byte order of the current session
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
SYSNOBS
The number of observations read from the last data set
SYSODSESCAPECHAR
The value of the ODS ESCAPECHAR= from within the program
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
SYSSIZEOFLONG
The length in bytes of a long integer in the current session
SYSSIZEOFPTR
The size in bytes of a pointer
SYSSIZEOFUNICODE
The length in bytes of a Unicode character in the current session
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