You can use date literials in %SYSFUNC(INTCK they just have to be
correct date7 or date9 format. In this case we need the day part.
0 %macro test( StartDate, EndDate);
11 %let EndDate=%sysfunc(intnx(month,"01&EndDate."d,1),date9);
12 %let StartDate=01&StartDate.;
13 %let where="&StartDate."d<=model<="&EndDate."d;
14 %put WHERE=&where;
15 %mend;
16
17 %test( jan09, dec09);
WHERE="01jan09"d<=model<="01JAN2010"d
On 1/13/10, Joe Matise <snoopy369@gmail.com> wrote:
> First off, I believe SYSFUNC arguments are intended to be unquoted (no ' "
> ). 'month' should be month (no quotes).
>
> Secondly, "&EndDate"d won't work in the SYSFUNC, as far as I can tell.
> You'll need to either pass it as a date value, or inside the sysfunc input
> it into a date value.
>
> Finally, you are recursively referenceing EndDate in the %let statement -
> probably not good idea. It doesn't do any harm, but it makes it difficult
> to see the errors.
>
> This works, for example:
>
> %macro test( StartDate, EndDate);
> %let EndDate=%sysfunc(intnx('month',&EndDate,1));
> %let StartDate=01&StartDate.;
> %let where="&StartDate."d<=model<="&EndDate."d;
> %mend(test);
>
> %test( jan09, 17198);
>
> -Joe
>
>
>
> On Wed, Jan 13, 2010 at 12:53 PM, Masoud Pajoh <mpajoh@odot.org> wrote:
>
> > All:
> > The following is a fragment of a much larger macro.
> >
> > %macro test( StartDate, EndDate);
> > %let EndDate=%sysfunc(intnx('month',"&EndDate."d,1));
> > %let StartDate=01&StartDate.;
> > %let where="&StartDate."d<=model<="&EndDate."d;
> > %mend(test);
> >
> > %test( jan09, dec09);
> >
> > WHERE should resolve to "01jan09"d<=model<="01jan10"d
> > But, I get:
> >
> > WARNING: An argument to the function INTNX referenced by the %SYSFUNC or
> > %QSYSFUNC macro function is out of range.
> >
> > What is wrong?
> >
> > Thanks,
> >
> > Masoud
> >
>
|