BookmarkSubscribeRSS Feed
DonH
Lapis Lazuli | Level 10
Based on some testing I just did in 9.2, it appears that some automatic macro variable can be declared to be local inside a macro. I tested sqlrc and SQL obs. Does anyone know of a comprehensive list of which automatics variables can be local?
5 REPLIES 5
data_null__
Jade | Level 19
I don't think they are _AUTOMATIC_. They are not printed by %put _AUTOMATIC_;

Since they are not created until the procedure executes, your comment would imply they follow the same rule as any other macro variable, with regards to scope.
DonH
Lapis Lazuli | Level 10
Hmmm. You are correct. I will have to find it as the person who asked me this claimed that it was listed on the doc site as an automatic macro variable. But I just ran the same check you did and also checked dictionary tables and neither of these are automatic.

Thx!
data_null__
Jade | Level 19
This note describes the behavior and calls them automatic. So I guess they are.

http://support.sas.com/kb/4/736.html
Peter_C
Rhodochrosite | Level 12
my "guess" is that any automatic macro variable to which you can assign a value, could be named on a %LOCAL
&syslast is an example I tried
438 %let syslast = something ;
439 %macro check1( name) ;
440 %local syslast ;
441 %let syslast = nothing ;
442 %put _local_ ;
443 %put &name = &&&name ;
444 %mend ;
445 %check1(syslast) ;
ERROR: Attempt to %LOCAL automatic macro variable SYSLAST.
CHECK1 NAME syslast
syslast = WORK.nothing
446 %put &syslast ;
WORK.nothing

So, that ERROR indicates a rule.
(which almosts demands an exception)

peterC
PatrickG
SAS Employee
Automatic macro variables are created by the macro processor when you invoke SAS. All of them are global except for SYSPBUFF which is local. But, you won't see it listed with a "%put _local_" because that only lists user-generated local macro variables.

Of the automatic macro variables that can be assigned values, they still remain global no matter where you assign the new value...

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 5 replies
  • 984 views
  • 0 likes
  • 4 in conversation