SYSLAST Automatic Macro Variable

Contains the name of the SAS data file created most recently.
Type: Automatic macro variable (read and write)
See: SYSDSN Automatic Macro Variable

Details

The name is stored in the form libref.dataset. You can insert a reference to SYSLAST directly into SAS code in place of a data set name. If no SAS data set has been created in the current program, the value of SYSLAST is _NULL_, with no leading or trailing blanks.
Note: The macro processor always stores the value of SYSLAST in unquoted form. To quote the resolved value of SYSLAST, use the %SUPERQ macro quoting function.

Comparisons

  • Assigning a value to SYSLAST is the same as specifying a value for the _LAST_= system option.
  • The value of SYSLAST is often more useful than SYSDSN because the value of SYSLAST is formatted so that you can insert a reference to it directly into SAS code in place of a data set name.

Example: Comparing Values Produced by SYSLAST and SYSDSN

Create the data set FIRSTLIB.SALESRPT and then enter the following statements:
%put Sysdsn produces:  *&sysdsn*;
%put Syslast produces: *&syslast*;
When these statements are executed, the following is written to the SAS log:
Sysdsn produces:  *FIRSTLIBSALESRPT*
Syslast produces: *FIRSTLIB.SALESRPT*
The name stored in SYSLAST contains the period between the libref and data set name.