| Date: | Fri, 16 Jul 2010 15:43:00 +1200 |
| Reply-To: | Tom Robinson <barefootguru@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Tom Robinson <barefootguru@GMAIL.COM> |
| Subject: | Re: Macro error... |
| In-Reply-To: | <201007151047.o6FAl53r008022@willow.cc.uga.edu> |
| Content-Type: | text/plain; charset=us-ascii |
I see now you received some replies under a slightly different topic. Just posting questions to the list once is good form.
Cheers
On 2010-07-15, at 22:47, SUBSCRIBE SAS-L Joe H. Smith wrote:
> Dear all ,
>
> i have written below code ..it always gives me error even after errors are
> debugged.
>
>
>
> %let years=2007;
> %let yeare=2008;
> %let MONTHS=03;
> %let MONTHE=03;
> %let NODATAMSG = 'Please enter a valid Ending Date';
>
>
> data _null_;
> IF &MONTHS = 01 THEN DAYE=31;
> else IF &MONTHS = 03 THEN DAYE=31;
> else IF &MONTHS = 04 THEN DAYE=30;
> else IF &MONTHS = 05 THEN DAYE=31;
> else IF &MONTHS = 06 THEN DAYE=30;
> else IF &MONTHS = 07 THEN DAYE=31;
> else IF &MONTHS = 08 THEN DAYE=31;
> else IF &MONTHS = 09 THEN DAYE=30;
> else IF &MONTHS = 10 THEN DAYE=31;
> else IF &MONTHS = 11 THEN DAYE=30;
> else IF &MONTHS = 12 THEN DAYE=31;
> else IF mod(&yeare,400)=0 and &MONTHE=02 THEN DAYE=29;
> else IF mod(&yeare,100)=0 and &MONTHE=02 THEN DAYE=28;
> else IF mod(&yeare,4) =0 and &MONTHE=02 THEN DAYE=29;
> else DAYE=28;
> BEGRPTDT_1=mdy(&MONTHS,01,&years);
> CALL SYMPUT('BEGRPTDT', PUT( BEGRPTDT_1,DATE9.));
>
> ENDRPTDT_1=mdy(&MONTHS,DAYE,&yeare);
> CALL SYMPUT('ENDRPTDT', PUT( ENDRPTDT_1,DATE9.));
> RUN;
>
> %let BEGRPTDT22 = &BEGRPTDT.;
> /*%put &BEGRPTDT2.;*/
>
> %let ENDRPTDT22 = &ENDRPTDT.;
>
> data _null_;
> call symput('BEGRPTDT2',PUT("&BEGRPTDT22."d,DATE9.));
> call symput('ENDRPTDT2',PUT("&ENDRPTDT22."d,DATE9.));
> BEGRPTDT1_1 = put(intnx('year',"&BEGRPTDT2."d,-1,'s'),date9.);
> call symput('BEGRPTDT1',BEGRPTDT1_1);
> YEARE_1 = "&YEARE" - 1;
> call symput('YEARE',YEARE_1);
> /*BEGPSEYR_1 = COMPRESS(YEAR("&ENDRPTDT."d) || '1001');*/
> BEGPSEYR_1 =mdy(01,10,YEAR("&ENDRPTDT."d));
> put BEGPSEYR_1;
> /*run;*/
> call symput('BEGPSEYR',BEGPSEYR_1);
> ENDPSEYR_1 = COMPRESS(YEAR("&ENDRPTDT."d) || '0930');
> call symput('ENDPSEYR',ENDPSEYR_1);
> m=month("&ENDRPTDT"d);
> d=day("&ENDRPTDT"d);
> my=compress(m)||compress(d);
> put m;
> put d;
> put my;
> if my <= 0930 then BEGPSEDT3_1 =put(intnx('year',BEGPSEYR_1,-
> 1,'s'),date9.);
> else BEGPSEDT3_1 =BEGPSEYR_1;
> call symput('BEGPSEDT3',BEGPSEDT3_1);
> R =INPUT( put(INPUT("&BEGPSEDT3",ANYDTDTE10.),date9.),DATE9.);
> put r;
> BEGPSEDT2_1 = intnx('year',R,-1,'s');
> BEGPSEDT2_2 = PUT(BEGPSEDT2_1,DATE9.);
> call symput('BEGPSEDT2',BEGPSEDT2_2);
> BEGPSEDT1_1 = intnx('year',R,-2,'s');
> BEGPSEDT1_2=PUT(BEGPSEDT1_1,DATE9.);
> call symput('BEGPSEDT1',BEGPSEDT1_2);
> m1=month("&ENDRPTDT"d);
> d1=day("&ENDRPTDT"d);
> my1=compress(m1)||compress(d1);
> If MY1 <= 0930 THEN ENDPSEDT3_1 =ENDPSEYR_1;
> ELSE ENDPSEDT3_1=MDY(M1,D1,COMPRESS(YEAR("&ENDRPTDT."d)));
> call symput('ENDPSEDT3',PUT(ENDPSEDT3_1,DATE9.));
> ENDPSEDT2_1 = put(intnx('year',"&ENDPSEDT3."D,-1,'s'),date9.);
> call symput('ENDPSEDT2',ENDPSEDT2_1);
> ENDPSEDT1_1 = put(intnx('year',"&ENDPSEDT3."D,-2,'s'),date9.);
> call symput('ENDPSEDT1',ENDPSEDT1_1);
> emon_1=month("&ENDRPTDT2"d);
> call symput('emon',emon_1);
> BMON_1=month("&BEGRPTDT2"d);
> call symput('BMON',BMON_1);
> /*put m;*/
> /*put y;*/
> /*put my;*/
> /*put m1;*/
> /*put y1;*/
> put my1;
> /*PUT BEGPSEDT1_1;*/
> /*PUT BEGPSEDT2_1;*/
> /*PUT BEGPSEDT3_1;*/
> /*PUT BEGPSEDT2_1;*/
> PUT ENDPSEDT3_1;
> PUT ENDPSEYR_1;
> RUN;
>
>
> 328 ENDPSEDT1_1 = put(intnx('year',"&ENDPSEDT3."D,-2,'s'),date9.);
> WARNING: Apparent symbolic reference ENDPSEDT3 not resolved.
> 329 call symput('ENDPSEDT1',ENDPSEDT1_1);
> 330 emon_1=month("&ENDRPTDT2"d);
> -------------
> 77
> WARNING: Apparent symbolic reference ENDRPTDT2 not resolved.
> ERROR: Invalid date/time/datetime constant "&ENDRPTDT2"d.
> ERROR 77-185: Invalid number conversion on "&ENDRPTDT2"d.
>
> 331 call symput('emon',emon_1);
> 332 BMON_1=month("&BEGRPTDT2"d);
> -------------
> 77
> WARNING: Apparent symbolic reference BEGRPTDT2 not resolved.
> ERROR: Invalid date/time/datetime constant "&BEGRPTDT2"d.
> ERROR 77-185: Invalid number conversion on "&BEGRPTDT2"d.
>
>
> Please help out as i am unable to debug..tried lot many times but still
> unable to find root cause ..please ...dont mind......
>
> THanks,
> MIKE
|