BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
whymath
Lapis Lazuli | Level 10
I am going to write some macro and want to know which one is more robuster.
1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

They will both reference the same dataset, if that is what you meant.

 

But they aren't the same thing at all.

 

_LAST_ is a keyword you can use in places where SAS syntax expects a dataset name.

 

SYSLAST is a macro variable.  You can use it anywhere you would use a macro variable.

View solution in original post

3 REPLIES 3
Quentin
Super User

Generally I'm not a fan of _LAST_ or &SYSLAST, and I think it was a bad language design decision to have a PROC step default to reading _LAST_ if no dataset is specified.

 

It's part of the language so it's not going to change, but I would avoid relying on either.

 

That said, I think they really might be the same thing.  I just noticed that if you assign a value the the macro variable SYSLAST, the value will be used by _LAST_, e.g.:

 

%let syslast=sashelp.class ;

proc print data=_last_(obs=3) ;
run ;

%let syslast=sashelp.shoes ;

proc print data=_last_(obs=3) ;
run ;

options _last_=sashelp.prdsale ;
%put &syslast ;

proc print ;
run ;

 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
Tom
Super User Tom
Super User

They will both reference the same dataset, if that is what you meant.

 

But they aren't the same thing at all.

 

_LAST_ is a keyword you can use in places where SAS syntax expects a dataset name.

 

SYSLAST is a macro variable.  You can use it anywhere you would use a macro variable.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 353 views
  • 4 likes
  • 4 in conversation