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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 849 views
  • 0 likes
  • 3 in conversation