Date: Tue, 28 Aug 2001 05:43:49 -0700
Reply-To: RAHUL CHAHAL <rahulchahal@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: RAHUL CHAHAL <rahulchahal@YAHOO.COM>
Subject: Re: Q to improve code using Macros
In-Reply-To: <759FC8B57540D311B14E00902727A0C0061A1AFE@a1mbx01.pharma.com>
Content-Type: text/plain; charset=us-ascii
Thanks Dennis, I am sure this will work and is a good
solution ... I was working on something like that this
morning. Appreciate it.
Kind Regards
-Rahul
--- "Diskin, Dennis" <Dennis.Diskin@pharma.com> wrote:
> The below macro should do what you asked. I have
> used variable names z1-z12
> instead of a b c... If these names are not available
> you can easily change
> to something else.
>
> hth,
> Dennis Diskin
>
>
> %macro makeaf(month);
> %local i;
> data allaf;
> merge crystal(in=z)
> %do i = 1 %to &month;
> af&i(in=z&i)
> %end;
> ;
> by applid;
> if z and (
> %do i = 1 %to &month;
> z&i
> %if &i ne &month %then %do; or %end;
> %end;
> );
> run;
> %mend makeaf;
>
>
> %makeaf(1);
>
>
> %makeaf(12);
>
> > -----Original Message-----
> > From: RAHUL CHAHAL [SMTP:rahulchahal@YAHOO.COM]
> > Sent: Monday, August 27, 2001 6:58 PM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: Q to improve code using Macros
> >
> > I have the following merge that with every month
> of
> > the year keeps adding a month .... wanted to know
> the
> > best way to put in a macro -
> >
> > In Feb it would be like:
> >
> > data allaf;
> > merge crystal(in=z) af1(in=a) af2(in=b);
> > by applid;
> > if (a or b) and z then output allaf;
> > run;
> >
> > In March it would be like:
> >
> > data allaf;
> > merge crystal(in=z) af1(in=a) af2(in=b)
> af3(in=c);
> > by applid;
> > if (a or b or c) and z then output allaf;
> > run;
> >
> > I am not sure how to solve the if condition within
> the
> > following macro-
> >
> > %macro mrgg(prefix=,from=,to=);
> >
> > data allaf;
> > merge crystal(in=z)
> > %do i=&from %to &to;
> > &prefix&i(in=&i)
> > %end;;;;
> > by applid;
> > if
> > %do i=&from %to &to;
> > &i /*<- Here I am wrong */
> > %end;;;;
> > and z;
> > run;
> > %mend;
> > %mrgg(prefix=af,from=1,to=2);
> >
> > Thanks to all to take the time to help.
> >
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute
> with Yahoo! Messenger
> > http://phonecard.yahoo.com/
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
|