BookmarkSubscribeRSS Feed
sandeep12
Fluorite | Level 6

What is the difference between %LOCAL and %GLOBAL?

6 REPLIES 6
Patrick
Opal | Level 21

Copy/paste the exact words below into a Google search:

sas What is the difference between %LOCAL and %GLOBAL

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Also search for macro variable scope.  

Tom
Super User Tom
Super User

They both are used to make sure macro variables are defined. The difference is where they are defined. %GLOBAL will define them in the global symbol table.  %LOCAL will define them in the symbol table for the currently running macro.  Once the current macro finishes running its symbol table disappears.

rinugour
Fluorite | Level 6

% Local is a macro variable defined inside a macro. %Global is a macro variable defined in open code (outside the macro or can use anywhere).

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Incorrect.  local or global indicates the scope of the macro variable.  You can create global macros within a macro for instance.  The default for macro variables created within a macro is local to the macro, however you can explicitly state the macro variable is global, and hence make it available outside.  As that doesn't really work with encapsulation, so default is local.  

 

There is clear guidance in the documentation about this:

http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#p1b76sxg9dbcyrn1l...

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 6 replies
  • 11150 views
  • 3 likes
  • 6 in conversation