Date: Fri, 29 Mar 1996 09:49:18 PST
Reply-To: TWB2%Rates%FAR@GO50.COMP.PGE.COM
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: TWB2%Rates%FAR@GO50.COMP.PGE.COM
Subject: Re: Calling Global Variables Conditionally from a Nested Macro
Joe, try changing &count&countparameter to &&count&countparameter in the inner
macro. When SAS scans a double ampersand, it stores a single ampersand and
rescans the line. Thus if &which is 3, &&parm&which scans into &parm3 and the
line is then rescanned so that &parm3 can be resolved. There are also times
when macro mavens will use &&& and &&&&, and probably even more (although by
the time I get to &&&&&&parm&&&&index&&ptr&num, I look for another approach).
&&&&&&parm&&&&index&&ptr&num assume &num is 5 resolves to
&&&parm&&index&ptr5 assume &ptr5 is 3 and &parm is cat resolves to
&cat&index3 assume &cat is angora and &index3 is Sassy Cat resolves to
angoraSassy Cat
----------------------[Reply - Original Message]----------------------
Sent by:Joe Carpenter <jcarpent@GNU.UVM.EDU>
I would appreciate any help in calling global variables conditionally
from a nested macro. The program structure is similar to the following:
%global COUNT1 COUNT2 COUNT3 COUNT4 COUNT5;
%macro one (parameters);
macro statements;
call symput statements to set up global vars;
invoke macro 2 with parameters 1, 2, 3, 4, or 5, depending on which
global count variable is needed;
%mend macro 1;
%macro2 (countparameter);
%if &count&countparameter > 0 %then %do; e.g., &count3
program statements;
%end;
%mend macro2;
I would appreciate help with the %if statement - how to have the macro
variable be read as &count1 to &count5, depending on invocation.
Joe Carpenter
Data Analyst, Biometry Facility
University of Vermont
(802) 656-0619 email: jcarpent@zoo.uvm.edu
=====================================================================