Date: Mon, 27 Sep 2004 10:02:03 -0500
Reply-To: "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Dunn, Toby" <Toby.Dunn@TEA.STATE.TX.US>
Subject: Re: Resolving Macros Part II
Content-Type: text/plain; charset="us-ascii"
Jim,
This is about as close as I could get to what you wanted:
%let C_Group = 76504;
%let C_Val = 0.4;
%let N_Group = 56183;
%let N_Val = 0.6;
%macro Get_Value(g,v);
%if &v <= &&&g._Group %then %do;
%let Weight= &&&g._Val;
%end;
%else %if &v > &&&g._Group %then %do;
%let Weight=1;
%end;
%mend;
data _null_;
group="C";
value=4000;
call execute('%Get_Value('||group||','||'value'||' )');
run;
data _null_;
weight = &weight;
put weight=;
Run;
HTH
Toby Dunn
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Jim
Hoffman
Sent: Monday, September 27, 2004 9:11 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Resolving Macros Part II
I am making another stab at defining my problem. Examples are provided.
I need to pass only the prefix of my macro variables and have it resolve
into the appropriate group and val. It works fine when I am passing the
specific character. It is when I use a variable that contains the
specified character that it fails.
%let C_Group = 76504;
%let C_Val = 0.4;
%let N_Group = 56183;
%let N_Val = 0.6;
%macro Get_Value(g=,v=);
/* Create lookup weighting for value */
if &v <= &&&g._Group then Weight = &&&g._Val;
else Weight = 1;
%mend;
data _null_;
group="C";
value=4000;
%get_value(g=group,v=value); /* This is the way I need to call macro */
%*get_value(g=C,v=4000); /* This work fine */
put weight=;
run;
Thanks again.