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 (August 2001, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 10 Aug 2001 11:43:26 -0700
Reply-To:     Dale McLerran <dmclerra@MY-DEJA.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Dale McLerran <dmclerra@MY-DEJA.COM>
Subject:      Re: Macro "array" warnings
Comments: To: rpearce@u.washington.edu
Content-Type: text/plain

Rachel,

Here is what the macro processor is doing when it scans the code

%if %index(%str(%upcase(&took&j)),%upcase(&supp&i))>0 %then %do;

The processor looks from left to right, examining each token as it goes. Now, it comes to the token &took. This token cannot be resolved. There is no variable &took, so you get the error message.

Now, if you prefix another ampersand to &took&j, so that you have &&took&j, here is what the macro processor will do. It will scan from left to right as before. When the double ampersand is encountered, then the double ampersand will resolve to the token &. The token took will resolve to took. And the token &j will resolve to the value of macro variable j. Let's suppose that the value of macro variable j is 3. Then piecing these tokens together, you will get the token &took3. After the macro processor has finished the first tokenization, it does another pass to see if there are any more tokens to resolve. On the second pass, the macro processor finds the token &took3 which can now be resolved to the value of macro variable took3.

So the fix to your problems is to use double ampersands:

%if %index(%str(%upcase(&&took&j)),%upcase(&&supp&i))>0 %then %do;

Dale

>Date: Fri, 10 Aug 2001 10:46:05 -0700 >Reply-To: Rachel Pearce <rpearce@U.WASHINGTON.EDU> > Rachel Pearce <rpearce@U.WASHINGTON.EDU> Macro "array" warnings SAS-L@LISTSERV.UGA.EDU >Hello all, > >I wonder if someone can help me with this simple but annoying problem. >I am probably doing something fundamentally wrong, but here goes: > >I have defined an "array" of macro variables took1.... took9, >and another array supp1...supp60. >Now when I want to look at these variables and compare them, I do things >like: > > %if %index(%str(%upcase(&took&j)),%upcase(&supp&i))>0 %then %do; > >Now this gets me in *lots* of trouble as I get warning messages: > >WARNING: Apparent symbolic reference TOOK not resolved. >WARNING: Apparent symbolic reference SUPP not resolved. > >Now of course they are not resolved, it is the subscripted "array" I want >resolved, but as these %ifs are inside loops I get thousands and thousands >of >warning messages, and consequently either fill the log window or get huge >unreadable log files. Can I avoid these messages somehow? Is there something >wrong with my macro variable referencing? > >Rachel

--------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@fhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 ---------------------------------------

------------------------------------------------------------ --== Sent via Deja.com ==-- http://www.deja.com/


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