Hi,
We can use any number of ampersands (&) in an indirect macro variable reference.
SAS resolves the entire reference from left to right. If a pair (double) of ampersands (&&) is encountered, the pair (double) is resolved to single ampersand, then the next part of the reference is processed.
Suppose we have following macro variables:
%let a=UMA;
%let UMA=SHANKER;
%let SHANKER=SAINI;
And we are going to check the output of the following PUT statements with multiple macro variables.
%put &a;
%put &&a;
%put &&&a;
%put &&&&a;
%put &&&&&a;
%put &&&&&&a;
%put &&&&&&&a;
And output would be something like this:
%put &a; * UMA *;
%put &&a; * UMA *;
%put &&&a; * SHANKER * ;
Explanation: && resolves to single & (put in reserve) resolve &a to UMA, now with reserve & sas reads &UMA , result is SHANKER.
%put &&&&a; * UMA . pairing && and && comes to && resolves to & *;
Explanation: && resolves to single & (put in reserve) again && resolve to single & (put in reserve), now we have only a, no execution. in reserve we have && which is &a. again result is UMA.
%put &&&&&a;
Explanation: && resolves to single & (put in reserve) again && resolve to single & (put in reserve), now we have &a, resolve to UMA. In reserve we have two ampersand, which is one (&) and now it is &UMA, resolve to SHANKER.
%put &&&&&&a;
Explanation: && resloves to single & (put in reserve) again && resolve to single & (put in reserve) , && resolve to single & (put in reserve), now we have only a , no execution. In reserve we have &&& so again result is SHANKER.
%put &&&&&&&a;
Explanation: Would resolve to SAINI, because we would have three ampersand (in reserve) and &a resolve to UMA. &&&UMA resolve to &SHANKER and it would resolve to SAINI.
We can use any number of ampersands (&) in an indirect macro variable reference.
SAS resolves the entire reference from left to right. If a pair (double) of ampersands (&&) is encountered, the pair (double) is resolved to single ampersand, then the next part of the reference is processed.
Suppose we have following macro variables:
%let a=UMA;
%let UMA=SHANKER;
%let SHANKER=SAINI;
And we are going to check the output of the following PUT statements with multiple macro variables.
%put &a;
%put &&a;
%put &&&a;
%put &&&&a;
%put &&&&&a;
%put &&&&&&a;
%put &&&&&&&a;
And output would be something like this:
%put &a; * UMA *;
%put &&a; * UMA *;
%put &&&a; * SHANKER * ;
Explanation: && resolves to single & (put in reserve) resolve &a to UMA, now with reserve & sas reads &UMA , result is SHANKER.
%put &&&&a; * UMA . pairing && and && comes to && resolves to & *;
Explanation: && resolves to single & (put in reserve) again && resolve to single & (put in reserve), now we have only a, no execution. in reserve we have && which is &a. again result is UMA.
%put &&&&&a;
Explanation: && resolves to single & (put in reserve) again && resolve to single & (put in reserve), now we have &a, resolve to UMA. In reserve we have two ampersand, which is one (&) and now it is &UMA, resolve to SHANKER.
%put &&&&&&a;
Explanation: && resloves to single & (put in reserve) again && resolve to single & (put in reserve) , && resolve to single & (put in reserve), now we have only a , no execution. In reserve we have &&& so again result is SHANKER.
%put &&&&&&&a;
Explanation: Would resolve to SAINI, because we would have three ampersand (in reserve) and &a resolve to UMA. &&&UMA resolve to &SHANKER and it would resolve to SAINI.


