DATA Step, Macro, Functions and more

Can anybody tell me how multilevel referencing works in macro?

Reply
Contributor
Posts: 27

Can anybody tell me how multilevel referencing works in macro?

%put &a &&&b &&&&&&&c;

How this works?

Super User
Posts: 10,035

Re: Can anybody tell me how multilevel referencing works in macro?

Posted in reply to bharathtuppad

Each time for two & .

&a

-> result_of_&a

&& &b

->&(result_of_&b)

&& && && &c

->& &   & (result_of_&c)

->  &   result_of_(& (result_of_&c)

Frequent Contributor
Posts: 118

Re: Can anybody tell me how multilevel referencing works in macro?

Posted in reply to bharathtuppad
Super User
Super User
Posts: 7,970

Re: Can anybody tell me how multilevel referencing works in macro?

Posted in reply to bharathtuppad

Seriously, just don't do it.  If your having to use more than one & in code, then I would suggest your programming it wrongly.  Think about the problem and the data differently, will transposing/normalising the data change the code, can you use arrays, or SQL aggregates etc.  Many ways to solve a problem.

SAS Super FREQ
Posts: 8,868

Re: Can anybody tell me how multilevel referencing works in macro?

Posted in reply to bharathtuppad

Hi:

  I agree with RW9 that references like &&&&a and &&&&&b are generally unnecessary, there are SOME indirect references to macro variables such as &&macvar&num that are quite useful, especially when you have numbered macro variables. I have an example of this in my paper on Macro Basics: http://support.sas.com/resources/papers/proceedings13/120-2013.pdf see Figure 18 and explanation on pages 10-11.

cynthia

Ask a Question
Discussion stats
  • 4 replies
  • 316 views
  • 0 likes
  • 5 in conversation