Date: Wed, 7 Oct 2009 10:46:18 -0500
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: related to macro..............
In-Reply-To: <20e5d12f0910070822i229842a0n3023549c762d1b22@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
That restriction applies to macro variables [you cannot assign a data step
value to a macro variable and then refer to it in the same data step, and
expect it to mean what you think it should mean] but it most certainly does
not apply in this case; he's not passing the value of X, but the actual
variable name.
Also, I don't understand your note about FCMP, I rather thought FCMP was
also for this purpose [data step functions]... though I'm no FCMP expert ...
-Joe
2009/10/7 Daniel Fernández <fdezdan@gmail.com>
> I am not sure if you receive my answer:
>
> I think your macro solution won´t work because SAS reads macro
> language first and later the non-macro language.
> Perhaps the nearest solution as a macro look-like will be a temp file:
>
> /* y is a function that depends on x,
> we only need to change the input dataset and output dataset on the
> following 2 macrovaraibles*/ %let have=test; %let need=test2; filename
> gupt temp; data _null_; file gupt; put 'data ' "&need" ';' /
> 'set ' "&have" ';' /
> 'y= (x**2)+(2*x)+3;' /
> 'run; ' ;
> run;
> %inc gupt /source2;
>
> I wanted to make it with a PROC FCMP but it is only usefull inside
> other procs :(
>
> Daniel Fernandez.
>
>
>
>
> 2009/10/7 RTSL.eu <rtsl@email.com>:
> > On 7 Oct, 12:51, gupt <pvsgu...@gmail.com> wrote:
> >> Hi, Sas experts,
> >>
> >> data test;
> >> input x;
> >> cards;
> >> 5
> >> 3
> >> 5
> >> 2
> >> 4
> >> ;
> >> run;
> >>
> >> i want to create test2 in which i want to include another variable
> >> y=x**2+2*x+3;
> >> i can write like the following;
> >> data test2;
> >> set test;
> >> y=x**2+2*x+3;
> >> run;
> >>
> >> but i want to use one user defined function instead of writing the
> >> above code.
> >> i.e ;
> >> data test2;
> >> set test;
> >> y=%somemacro();
> >> run;
> >>
> >> i am not able to prepare this macro.......... if anybody help me it
> >> will be very great help to me.
> >
> > How about...
> >
> > options mprint;
> >
> > %macro somemacro(var);
> > y=&var**2+2*&var+3;
> > %mend somemacro;
> >
> > data test2;
> > set test;
> > y=%somemacro(x);
> > run;
> >
> > -Andy
> > SAS Blog: www.NoteColon.info
> >
>
|