Date: Mon, 27 Sep 2004 07:15:58 -0700
Reply-To: W Dennis Diskin <diskin@ALUM.RPI.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: W Dennis Diskin <diskin@ALUM.RPI.EDU>
Subject: Re: Resolving Macros Part II
Content-Type: text/plain; charset="iso-8859-1"
Jim,
You can't pass a data step variable value to a macro because the macro
is interperted at compile time, before the dataset has been opened. One
way to implement what you are attempting might be:
data _null_;
group="C";
value=4000;
select (group);
when("C") do;
%get_value(g=C,v=4000);
end;
when("N") do;
%get_value(g=N,v=4000);
end;
end;
put weight=;
run;
HTH,
Dennis Diskin
<-----Original Message----->
From: Jim Hoffman
Sent: 9/27/2004 10:19:32 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.
.