LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments:   To: frankplank55@YAHOO.COM

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** */


Back to: Top of message | Previous page | Main SAS-L page