Chapter Contents

Previous

Next
SAS Macro Language: Reference

Macro Variables Defined by the SAS System

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 SYSDATE:

footnote "Report for &sysday, &sysdate";

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

FOOTNOTE "Report for Tuesday, 17DEC96";

Automatic macro variables are often useful in conditional logic such as a %IF statement with actions determined by the value that is returned. %IF is described in Chapter 13.

You can assign values to automatic macro variables that have read/write status. However, you cannot assign a value to an automatic macro variable that has read-only status. Automatic Macro Variables by Category lists the automatic macro variables that are supplied by base SAS software and their read/write status. They are described in Chapter 13.

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 Chapter 11. Other SAS software products also provide macro variables, which are described in the documentation for the product that uses them.

Automatic Macro Variables by Category
Status Variable Contains
Read/Write SYSBUFFER 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

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

SYSENV foreground or background indicator

SYSERR return code set by SAS procedures and the DATA step

SYSINDEX number of macros that have begun execution during this session

SYSINFO return code information

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

SYSMENV current macro execution environment

SYSPROCESSID the process id of the current SAS process

SYSPROCESSNAME the process name of the current SAS process

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

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

SYSUSERID the userid 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


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.