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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1366 views
  • 0 likes
  • 4 in conversation