104 users online | 104 Guests and 0 Registered

Can SAS identify the last-created dataset?


Macro Variable

It is possible to omit the DATA= option from a PROC statement, and the system will then use the last-created dataset for processing.

The stored value can be seen in the SYSLAST automatic macro variable; which has a default value of _NULL_ at the start of a new session.

The SYSLAST variable is one of those automatic variables whose value can be altered - simply submit code which generates a dataset, and the value will be updated.

Consider the code (submitted at the start of a new session):

%put &=syslast ;

data over12 ;
  set sashelp.class ;
    where age > 12 ;
run ;

%put &=syslast ;

proc print ;
run ;

which generates values in the LOG as follows:

SYSLAST=_NULL_
SYSLAST=WORK.OVER12

and produces a listing report.

 

Global System Option

This is not the only source of the last-created dataset, however.  There is also a global system option _LAST_= which can specify any temporary, or permanent dataset.  This over-rides the default value, and remains in force until another datset is created.

Amending the code, in a new session:

options _last_=sashelp.class ;

proc print ;
run ;

data over12 ;
  set sashelp.class ;
    where age > 12 ;
run ;

proc print ;
run ;

 

Listing reports of each of the SASHELP.CLASS and WORK.OVER12 datasets are produced.

Author:
Alan D Rudland
Revision:
1.0
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category

Tags