Date: Tue, 6 Sep 2005 11:33:01 -0400
Reply-To: Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject: Re: Macro variable indirection
On Tue, 6 Sep 2005 07:34:44 -0700, frankplank <frankplank55@YAHOO.COM>
wrote:
>Hi All,
>When building a hierarchy of macro variables, I guess there are a
>couple ways to go. There is the 'horizontal' method:
>** nested do loops here **
>&&&&Student&&Subject&Grade
>** end nested do loops **
>
>But I am wondering if there is a more pointer-like method. So far, I
>have no luck getting it to work:
>
>%let Varname=Student;
>%let Student=John;
>
>Now, I would like to use variable Varname to reference the value
>'John':
>%if (&&&Varname eq John) %then %do;
>...
>%end;
>
>Is there some combination of ampersands that will allow indirection, or
>some other macro trick?
Hi, Frank,
Three ampersends works for me. For resolving many layers of macro
indirections, see Richard's ResolveIt macro available at: http://devenezia.
com/downloads/sas/macros/index.php?m=resolveIt
Cheers,
Chang
%let varname = student;
%let student = john;
%put **&&&varname**;
/* on log
**john**
*/
|