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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 303 views
  • 0 likes
  • 3 in conversation