Date: Mon, 19 Oct 2009 09:11:27 -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: Why does this not work?
In-Reply-To: <20091019155010.65031l9y05w3z05u@webmail.nfit.au.dk>
Content-Type: text/plain; charset=ISO-8859-1
You might want to include some data. In general I'd say you should use
DO WHILE (aar<slutaar or ugenr<slutuge);
as it protects you from the situation of aar starts out higher than slutaar.
You also should have the RUN statement inside the macro, not outside of it.
-Joe
On Mon, Oct 19, 2009 at 8:50 AM, HÃ¥kan Lane <hlane@cls.dk> wrote:
> Inside a macro, I want to loop from a start year and week to the end
> year and week. I do this with a do loop with what seems to be very
> trivial statements. This is a simple version of the code that we have:
>
> %Macro mm(pnrcif);
> DATA b;
> SET b;
> WHERE MOD(pnr,10) = &pnrcif;
> aar = startaar;
> ugenr = startuge;
> DO WHILE NOT (aar = slutaar AND ugenr=slutuge);
> OUTPUT;
> IF (ugenr < 52) THEN ugenr = ugenr + 1;
> ELSE DO;
> ugenr = 1;
> aar = aar + 1;
> END;
> END;
> OUTPUT;
> %MEND;
>
> %mm(0);
> RUN;
>
> Yet it does not work. Either it gets stuck in the loop indefinitely
> (until out of resources) or it gives me a 22-322 error with some of
> the syntax. A hint to solve this would be very much appreciated.
>
> Regards,
>
> Håkan Lane
>
|