BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MBKo
Calcite | Level 5

Taking an example from a SAS book:  The code is: %global %scan(&varlist, &wrd)max;

Say, %scan(&varlist, &wrd) evaluates to 'age'.

The %global statement then creates the macro variable 'agemax'.

I cannot find documentation that tells me that this %global statement concatenates the results of %scan with 'max'.  Can anybody point me to that?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Once the macro processor has finished processing something like:

%scan(age sex race,1)max

The resulting string "agemax" is then used in evaluating the larger expression it is part of.  So

%global %scan(age sex race,1)max ;

Becomes 

%global agemax ;

 This type of text substitution is the exactly what "macro processors" are used for in any language, whether it is SAS , assembly or C.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Once the macro processor has finished processing something like:

%scan(age sex race,1)max

The resulting string "agemax" is then used in evaluating the larger expression it is part of.  So

%global %scan(age sex race,1)max ;

Becomes 

%global agemax ;

 This type of text substitution is the exactly what "macro processors" are used for in any language, whether it is SAS , assembly or C.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 2 replies
  • 947 views
  • 0 likes
  • 3 in conversation