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

Yes,

 

You retrieve macrovariables values in a SAS dataset columns but you still use the macrovariables

in your coalesce call instead of the dataset variables.

gamotte
Rhodochrosite | Level 12

Hello,

 

You can declare the macrovariable to ensure that it exists in all contexts.

If it has already be defined, the declaration will not change its value and if

not it will be defined as a space character, which is SAS way to define missing

character variables.

 

How you declare a macrovariable without setting its value depends on the context.

"%global" gives the macrovariable a global scope and "%local", in a macro, limits

the sccope to the macro body. Redeclaring as global a macrovariable which has already

been defined in the local context results in an error.

 

1    %let _LEGAL_CD=RMN;
2
3    %global _SOURCE_CD;
4
5    data l;
6    lel=compress(COALESCEC("&_SOURCE_CD.","&_LEGAL_CD."));
7    call symput('lel',lel);
8    run;

NOTE: The data set WORK.L has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           4.09 seconds
      cpu time            0.00 seconds


9
10   %put &=lel.;
LEL=RMN

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 16 replies
  • 3498 views
  • 12 likes
  • 5 in conversation