Concatenation of Macro Variables

<<< Click here to go back


Concatenation of macro variables


Many a times, we need to concatenate the macro variables in macro programs.

Suppose we define two global macro variables :

%Let Variable = Country;
%Let  N           = 4 ;

Also We have third macro variable  "Country4" which is actually concatenation of above two variables' value.

%Let Country4  = India ;

Now suppose, we need to population "India" using first two variables, we need to concatenate  the macro variables.

We write  >>>    &&&Variable.&N.

Try :

%put &&&Variable.&N. ;


Now let's understand how SAS resolves it.

SAS resolved such concatenated variables step wise, here in the step 1, it would be resolved into :

Basically First && resolves to &, &Variable. resolves to Country, &N. resolves to 4.

So as a result in first step it becomes &Country4. Now as Country4 is already a global variable, it resolves to India with the help of residual &.



Hope this is clear to you,  Let us then move ahead !



No comments:

Post a Comment

Do provide us your feedback, it would help us serve your better.