9791 * racedtck.sas Daniel Brockman 070721 race dtchk ; 9792 9793 options ls=80 symbolgen mprint mlogic ; 9794 9795 %let dir=C:/b/SAS-X405.5 ; 9796 %let subdir=&dir/sub ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 9797 %let datadir=&dir/data ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 9798 9799 libname mydata "&datadir" ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data NOTE: Libref MYDATA was successfully assigned as follows: Engine: V9 Physical Name: C:\b\SAS-X405.5\data 9800 9801 %include "&subdir/dtchk.sas" ; SYMBOLGEN: Macro variable SUBDIR resolves to C:/b/SAS-X405.5/sub 9986 9987 9988 data mydataset ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data 9989 infile "&datadir\megadate.txt"; * a set of dates ; 9990 input yr mo dy ; 9991 9992 run; NOTE: The infile "C:/b/SAS-X405.5/data\megadate.txt" is: File Name=C:\b\SAS-X405.5\data\megadate.txt, RECFM=V,LRECL=256 NOTE: 1000000 records were read from the infile "C:/b/SAS-X405.5/data\megadate.txt". The minimum record length was 5. The maximum record length was 10. NOTE: The data set WORK.MYDATASET has 1000000 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 4.79 seconds cpu time 2.03 seconds SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 9993 9994 %put "start " &sysdate= &systime= ; "start " 21JUL07= 16:32= 9995 %dtchk(mydataset,yr,mo,dy); MLOGIC(DTCHK): Beginning execution. MLOGIC(DTCHK): Parameter ISET has value mydataset MLOGIC(DTCHK): Parameter YR has value yr MLOGIC(DTCHK): Parameter MO has value mo MLOGIC(DTCHK): Parameter DY has value dy MPRINT(DTCHK): data _NULL_ ; SYMBOLGEN: Macro variable ISET resolves to mydataset MPRINT(DTCHK): set mydataset ; MPRINT(DTCHK): * number of days in each month of non-leap year ; MPRINT(DTCHK): good=1; MPRINT(DTCHK): * starting assumption: date is good ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (dy ne int(dy)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo ne int(mo)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (yr ne int(yr)) then good=0; MPRINT(DTCHK): * yr not an integer? ; MPRINT(DTCHK): else do; MPRINT(DTCHK): * all integers ? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<100) then do; MPRINT(DTCHK): * 2 digit year? ; MPRINT(DTCHK): tyyyy = year(today()); MPRINT(DTCHK): * this year ; MPRINT(DTCHK): tcc = int(tyyyy/100) ; MPRINT(DTCHK): * this century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): tccyr = tcc*100 + yr ; MPRINT(DTCHK): * this year if yr is in this century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tccyr - tyyyy > 50) then tcc=tcc-1 ; MPRINT(DTCHK): * yr must be prev century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tyyyy - tccyr >=50) then tcc=tcc+1 ; MPRINT(DTCHK): * yr must be next century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): yr = tcc*100 + yr ; MPRINT(DTCHK): * we will work with this year number ; MPRINT(DTCHK): end ; MPRINT(DTCHK): * 2 digit year ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<1 or yr>9999) then good=0; MPRINT(DTCHK): * yr out of range?; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo<1 or mo>12) then good=0; MPRINT(DTCHK): * mo out of range?; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if (dy<1 or dy>31) then good=0; MPRINT(DTCHK): * dy out of range?; SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo = 2) then do; MPRINT(DTCHK): * February?? ; MPRINT(DTCHK): * discover whether leap year ; MPRINT(DTCHK): leap=0 ; MPRINT(DTCHK): * assume not a leap year; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (mod(yr,400)=0) then leap=1; MPRINT(DTCHK): * yr divides by 400? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,100)=0) then leap = 0 ; MPRINT(DTCHK): * century yr? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,4)=0) then leap=1 ; MPRINT(DTCHK): * yr divides by 4? ; MPRINT(DTCHK): else leap = 0 ; MPRINT(DTCHK): * regular year ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (leap and dy>29) then good=0; MPRINT(DTCHK): * >29 days in leap yr? ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if ((not leap) and dy>28) then good=0; MPRINT(DTCHK): * >28 days in regular yr? ; MPRINT(DTCHK): end; MPRINT(DTCHK): * February ; MPRINT(DTCHK): else do ; MPRINT(DTCHK): * some other month? ; MPRINT(DTCHK): * too many days? ; MPRINT(DTCHK): * if (&dy>dpm(&mo)) then good=0; MPRINT(DTCHK): * too many days? ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): if (dy>30 and (mo=9 or mo=4 or mo=6 or mo=11)) then good=0; MPRINT(DTCHK): end; MPRINT(DTCHK): * some other month ; MPRINT(DTCHK): end; MPRINT(DTCHK): * all integers ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (not good) then put 'ERROR BAD DATE ' _N_= ' ' yr= ' ' mo= ' ' dy= ; MLOGIC(DTCHK): Ending execution. 9996 %put "end " &sysdate= &systime= ; SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 "end " 21JUL07= 16:32= 9997 9998 run; ERROR BAD DATE _N_=65184 yr=. mo=. dy=. ERROR BAD DATE _N_=97355 yr=. mo=. dy=. ERROR BAD DATE _N_=225824 yr=. mo=. dy=. ERROR BAD DATE _N_=312857 yr=. mo=. dy=. ERROR BAD DATE _N_=331639 yr=. mo=. dy=. ERROR BAD DATE _N_=355268 yr=. mo=. dy=. ERROR BAD DATE _N_=359226 yr=. mo=. dy=. ERROR BAD DATE _N_=477907 yr=. mo=. dy=. ERROR BAD DATE _N_=823713 yr=. mo=. dy=. ERROR BAD DATE _N_=943009 yr=. mo=. dy=. NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 10 at 1:185 10 at 2:2 10 at 2:71 10 at 3:119 10 at 3:187 10 at 5:9 10 at 5:91 NOTE: There were 1000000 observations read from the data set WORK.MYDATASET. NOTE: DATA statement used (Total process time): real time 0.65 seconds cpu time 0.62 seconds 9999 *--------------------------------------------; 10000 * racedtck.sas Daniel Brockman 070721 race dtchk ; 10001 10002 options ls=80 symbolgen mprint mlogic ; 10003 10004 %let dir=C:/b/SAS-X405.5 ; 10005 %let subdir=&dir/sub ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 10006 %let datadir=&dir/data ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 10007 10008 libname mydata "&datadir" ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data NOTE: Libref MYDATA was successfully assigned as follows: Engine: V9 Physical Name: C:\b\SAS-X405.5\data 10009 10010 %include "&subdir/dtchk.sas" ; SYMBOLGEN: Macro variable SUBDIR resolves to C:/b/SAS-X405.5/sub 10195 10196 10197 data mydataset ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data 10198 infile "&datadir\megadate.txt"; * a set of dates ; 10199 input yr mo dy ; 10200 10201 run; NOTE: The infile "C:/b/SAS-X405.5/data\megadate.txt" is: File Name=C:\b\SAS-X405.5\data\megadate.txt, RECFM=V,LRECL=256 NOTE: 1000000 records were read from the infile "C:/b/SAS-X405.5/data\megadate.txt". The minimum record length was 5. The maximum record length was 10. NOTE: The data set WORK.MYDATASET has 1000000 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 3.75 seconds cpu time 2.12 seconds SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 10202 10203 %put "start " &sysdate= &systime= ; "start " 21JUL07= 16:32= 10204 %dtchk(mydataset,yr,mo,dy); MLOGIC(DTCHK): Beginning execution. MLOGIC(DTCHK): Parameter ISET has value mydataset MLOGIC(DTCHK): Parameter YR has value yr MLOGIC(DTCHK): Parameter MO has value mo MLOGIC(DTCHK): Parameter DY has value dy MPRINT(DTCHK): data _NULL_ ; SYMBOLGEN: Macro variable ISET resolves to mydataset MPRINT(DTCHK): set mydataset ; MPRINT(DTCHK): * number of days in each month of non-leap year ; MPRINT(DTCHK): good=1; MPRINT(DTCHK): * starting assumption: date is good ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (dy ne int(dy)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo ne int(mo)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (yr ne int(yr)) then good=0; MPRINT(DTCHK): * yr not an integer? ; MPRINT(DTCHK): else do; MPRINT(DTCHK): * all integers ? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<100) then do; MPRINT(DTCHK): * 2 digit year? ; MPRINT(DTCHK): tyyyy = year(today()); MPRINT(DTCHK): * this year ; MPRINT(DTCHK): tcc = int(tyyyy/100) ; MPRINT(DTCHK): * this century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): tccyr = tcc*100 + yr ; MPRINT(DTCHK): * this year if yr is in this century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tccyr - tyyyy > 50) then tcc=tcc-1 ; MPRINT(DTCHK): * yr must be prev century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tyyyy - tccyr >=50) then tcc=tcc+1 ; MPRINT(DTCHK): * yr must be next century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): yr = tcc*100 + yr ; MPRINT(DTCHK): * we will work with this year number ; MPRINT(DTCHK): end ; MPRINT(DTCHK): * 2 digit year ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<1 or yr>9999) then good=0; MPRINT(DTCHK): * yr out of range?; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo<1 or mo>12) then good=0; MPRINT(DTCHK): * mo out of range?; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if (dy<1 or dy>31) then good=0; MPRINT(DTCHK): * dy out of range?; SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo = 2) then do; MPRINT(DTCHK): * February?? ; MPRINT(DTCHK): * discover whether leap year ; MPRINT(DTCHK): leap=0 ; MPRINT(DTCHK): * assume not a leap year; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (mod(yr,400)=0) then leap=1; MPRINT(DTCHK): * yr divides by 400? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,100)=0) then leap = 0 ; MPRINT(DTCHK): * century yr? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,4)=0) then leap=1 ; MPRINT(DTCHK): * yr divides by 4? ; MPRINT(DTCHK): else leap = 0 ; MPRINT(DTCHK): * regular year ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (leap and dy>29) then good=0; MPRINT(DTCHK): * >29 days in leap yr? ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if ((not leap) and dy>28) then good=0; MPRINT(DTCHK): * >28 days in regular yr? ; MPRINT(DTCHK): end; MPRINT(DTCHK): * February ; MPRINT(DTCHK): else do ; MPRINT(DTCHK): * some other month? ; MPRINT(DTCHK): * too many days? ; MPRINT(DTCHK): * if (&dy>dpm(&mo)) then good=0; MPRINT(DTCHK): * too many days? ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): if (dy>30 and (mo=9 or mo=4 or mo=6 or mo=11)) then good=0; MPRINT(DTCHK): end; MPRINT(DTCHK): * some other month ; MPRINT(DTCHK): end; MPRINT(DTCHK): * all integers ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (not good) then put 'ERROR BAD DATE ' _N_= ' ' yr= ' ' mo= ' ' dy= ; MLOGIC(DTCHK): Ending execution. 10205 %put "end " &sysdate= &systime= ; SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 "end " 21JUL07= 16:32= 10206 10207 run; ERROR BAD DATE _N_=65184 yr=. mo=. dy=. ERROR BAD DATE _N_=97355 yr=. mo=. dy=. ERROR BAD DATE _N_=225824 yr=. mo=. dy=. ERROR BAD DATE _N_=312857 yr=. mo=. dy=. ERROR BAD DATE _N_=331639 yr=. mo=. dy=. ERROR BAD DATE _N_=355268 yr=. mo=. dy=. ERROR BAD DATE _N_=359226 yr=. mo=. dy=. ERROR BAD DATE _N_=477907 yr=. mo=. dy=. ERROR BAD DATE _N_=823713 yr=. mo=. dy=. ERROR BAD DATE _N_=943009 yr=. mo=. dy=. NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 10 at 1:185 10 at 2:2 10 at 2:71 10 at 3:119 10 at 3:187 10 at 5:9 10 at 5:91 NOTE: There were 1000000 observations read from the data set WORK.MYDATASET. NOTE: DATA statement used (Total process time): real time 1.43 seconds cpu time 0.59 seconds 10208 *--------------------------------------------; 10209 * racedtck.sas Daniel Brockman 070721 race dtchk ; 10210 10211 options ls=80 symbolgen mprint mlogic ; 10212 10213 %let dir=C:/b/SAS-X405.5 ; 10214 %let subdir=&dir/sub ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 10215 %let datadir=&dir/data ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 10216 10217 libname mydata "&datadir" ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data NOTE: Libref MYDATA was successfully assigned as follows: Engine: V9 Physical Name: C:\b\SAS-X405.5\data 10218 10219 %include "&subdir/dtchk.sas" ; SYMBOLGEN: Macro variable SUBDIR resolves to C:/b/SAS-X405.5/sub 10404 10405 10406 data mydataset ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data 10407 infile "&datadir\megadate.txt"; * a set of dates ; 10408 input yr mo dy ; 10409 10410 run; NOTE: The infile "C:/b/SAS-X405.5/data\megadate.txt" is: File Name=C:\b\SAS-X405.5\data\megadate.txt, RECFM=V,LRECL=256 NOTE: 1000000 records were read from the infile "C:/b/SAS-X405.5/data\megadate.txt". The minimum record length was 5. The maximum record length was 10. NOTE: The data set WORK.MYDATASET has 1000000 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 3.73 seconds cpu time 1.90 seconds SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 10411 10412 %put "start " &sysdate= &systime= ; "start " 21JUL07= 16:32= 10413 %dtchk(mydataset,yr,mo,dy); MLOGIC(DTCHK): Beginning execution. MLOGIC(DTCHK): Parameter ISET has value mydataset MLOGIC(DTCHK): Parameter YR has value yr MLOGIC(DTCHK): Parameter MO has value mo MLOGIC(DTCHK): Parameter DY has value dy MPRINT(DTCHK): data _NULL_ ; SYMBOLGEN: Macro variable ISET resolves to mydataset MPRINT(DTCHK): set mydataset ; MPRINT(DTCHK): * number of days in each month of non-leap year ; MPRINT(DTCHK): good=1; MPRINT(DTCHK): * starting assumption: date is good ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (dy ne int(dy)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo ne int(mo)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (yr ne int(yr)) then good=0; MPRINT(DTCHK): * yr not an integer? ; MPRINT(DTCHK): else do; MPRINT(DTCHK): * all integers ? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<100) then do; MPRINT(DTCHK): * 2 digit year? ; MPRINT(DTCHK): tyyyy = year(today()); MPRINT(DTCHK): * this year ; MPRINT(DTCHK): tcc = int(tyyyy/100) ; MPRINT(DTCHK): * this century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): tccyr = tcc*100 + yr ; MPRINT(DTCHK): * this year if yr is in this century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tccyr - tyyyy > 50) then tcc=tcc-1 ; MPRINT(DTCHK): * yr must be prev century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tyyyy - tccyr >=50) then tcc=tcc+1 ; MPRINT(DTCHK): * yr must be next century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): yr = tcc*100 + yr ; MPRINT(DTCHK): * we will work with this year number ; MPRINT(DTCHK): end ; MPRINT(DTCHK): * 2 digit year ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<1 or yr>9999) then good=0; MPRINT(DTCHK): * yr out of range?; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo<1 or mo>12) then good=0; MPRINT(DTCHK): * mo out of range?; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if (dy<1 or dy>31) then good=0; MPRINT(DTCHK): * dy out of range?; SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo = 2) then do; MPRINT(DTCHK): * February?? ; MPRINT(DTCHK): * discover whether leap year ; MPRINT(DTCHK): leap=0 ; MPRINT(DTCHK): * assume not a leap year; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (mod(yr,400)=0) then leap=1; MPRINT(DTCHK): * yr divides by 400? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,100)=0) then leap = 0 ; MPRINT(DTCHK): * century yr? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,4)=0) then leap=1 ; MPRINT(DTCHK): * yr divides by 4? ; MPRINT(DTCHK): else leap = 0 ; MPRINT(DTCHK): * regular year ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (leap and dy>29) then good=0; MPRINT(DTCHK): * >29 days in leap yr? ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if ((not leap) and dy>28) then good=0; MPRINT(DTCHK): * >28 days in regular yr? ; MPRINT(DTCHK): end; MPRINT(DTCHK): * February ; MPRINT(DTCHK): else do ; MPRINT(DTCHK): * some other month? ; MPRINT(DTCHK): * too many days? ; MPRINT(DTCHK): * if (&dy>dpm(&mo)) then good=0; MPRINT(DTCHK): * too many days? ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): if (dy>30 and (mo=9 or mo=4 or mo=6 or mo=11)) then good=0; MPRINT(DTCHK): end; MPRINT(DTCHK): * some other month ; MPRINT(DTCHK): end; MPRINT(DTCHK): * all integers ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (not good) then put 'ERROR BAD DATE ' _N_= ' ' yr= ' ' mo= ' ' dy= ; MLOGIC(DTCHK): Ending execution. 10414 %put "end " &sysdate= &systime= ; SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 "end " 21JUL07= 16:32= 10415 10416 run; ERROR BAD DATE _N_=65184 yr=. mo=. dy=. ERROR BAD DATE _N_=97355 yr=. mo=. dy=. ERROR BAD DATE _N_=225824 yr=. mo=. dy=. ERROR BAD DATE _N_=312857 yr=. mo=. dy=. ERROR BAD DATE _N_=331639 yr=. mo=. dy=. ERROR BAD DATE _N_=355268 yr=. mo=. dy=. ERROR BAD DATE _N_=359226 yr=. mo=. dy=. ERROR BAD DATE _N_=477907 yr=. mo=. dy=. ERROR BAD DATE _N_=823713 yr=. mo=. dy=. ERROR BAD DATE _N_=943009 yr=. mo=. dy=. NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 10 at 1:185 10 at 2:2 10 at 2:71 10 at 3:119 10 at 3:187 10 at 5:9 10 at 5:91 NOTE: There were 1000000 observations read from the data set WORK.MYDATASET. NOTE: DATA statement used (Total process time): real time 0.67 seconds cpu time 0.67 seconds 10417 *--------------------------------------------; 10418 * racedtck.sas Daniel Brockman 070721 race dtchk ; 10419 10420 options ls=80 symbolgen mprint mlogic ; 10421 10422 %let dir=C:/b/SAS-X405.5 ; 10423 %let subdir=&dir/sub ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 10424 %let datadir=&dir/data ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 10425 10426 libname mydata "&datadir" ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data NOTE: Libref MYDATA was successfully assigned as follows: Engine: V9 Physical Name: C:\b\SAS-X405.5\data 10427 10428 %include "&subdir/dtchk.sas" ; SYMBOLGEN: Macro variable SUBDIR resolves to C:/b/SAS-X405.5/sub 10611 10612 10613 data mydataset ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data 10614 infile "&datadir\megadate.txt"; * a set of dates ; 10615 input yr mo dy ; 10616 10617 run; NOTE: The infile "C:/b/SAS-X405.5/data\megadate.txt" is: File Name=C:\b\SAS-X405.5\data\megadate.txt, RECFM=V,LRECL=256 NOTE: 1000000 records were read from the infile "C:/b/SAS-X405.5/data\megadate.txt". The minimum record length was 5. The maximum record length was 10. NOTE: The data set WORK.MYDATASET has 1000000 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 4.43 seconds cpu time 2.06 seconds SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 10618 10619 %put "start " &sysdate= &systime= ; "start " 21JUL07= 16:32= 10620 %dtchk(mydataset,yr,mo,dy); MLOGIC(DTCHK): Beginning execution. MLOGIC(DTCHK): Parameter ISET has value mydataset MLOGIC(DTCHK): Parameter YR has value yr MLOGIC(DTCHK): Parameter MO has value mo MLOGIC(DTCHK): Parameter DY has value dy MPRINT(DTCHK): data _NULL_ ; SYMBOLGEN: Macro variable ISET resolves to mydataset MPRINT(DTCHK): set mydataset ; MPRINT(DTCHK): * number of days in each month of non-leap year ; MPRINT(DTCHK): * days per month ; MPRINT(DTCHK): a1=31; MPRINT(DTCHK): a2=28 ; MPRINT(DTCHK): a3=31 ; MPRINT(DTCHK): a4=30 ; MPRINT(DTCHK): a5=31 ; MPRINT(DTCHK): a6=30 ; MPRINT(DTCHK): a7=31 ; MPRINT(DTCHK): a8=31 ; MPRINT(DTCHK): a9=30 ; MPRINT(DTCHK): a10=31 ; MPRINT(DTCHK): a11=30 ; MPRINT(DTCHK): a12=31 ; MPRINT(DTCHK): array dpm(12) a1-a12; MPRINT(DTCHK): good=1; MPRINT(DTCHK): * starting assumption: date is good ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (dy ne int(dy)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo ne int(mo)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (yr ne int(yr)) then good=0; MPRINT(DTCHK): * yr not an integer? ; MPRINT(DTCHK): else do; MPRINT(DTCHK): * all integers ? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<100) then do; MPRINT(DTCHK): * 2 digit year? ; MPRINT(DTCHK): tyyyy = year(today()); MPRINT(DTCHK): * this year ; MPRINT(DTCHK): tcc = int(tyyyy/100) ; MPRINT(DTCHK): * this century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): tccyr = tcc*100 + yr ; MPRINT(DTCHK): * this year if yr is in this century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tccyr - tyyyy > 50) then tcc=tcc-1 ; MPRINT(DTCHK): * yr must be prev century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tyyyy - tccyr >=50) then tcc=tcc+1 ; MPRINT(DTCHK): * yr must be next century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): yr = tcc*100 + yr ; MPRINT(DTCHK): * we will work with this year number ; MPRINT(DTCHK): end ; MPRINT(DTCHK): * 2 digit year ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<1 or yr>9999) then good=0; MPRINT(DTCHK): * yr out of range?; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo<1 or mo>12) then good=0; MPRINT(DTCHK): * mo out of range?; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if (dy<1 or dy>31) then good=0; MPRINT(DTCHK): * dy out of range?; SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo = 2) then do; MPRINT(DTCHK): * February?? ; MPRINT(DTCHK): * discover whether leap year ; MPRINT(DTCHK): leap=0 ; MPRINT(DTCHK): * assume not a leap year; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (mod(yr,400)=0) then leap=1; MPRINT(DTCHK): * yr divides by 400? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,100)=0) then leap = 0 ; MPRINT(DTCHK): * century yr? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,4)=0) then leap=1 ; MPRINT(DTCHK): * yr divides by 4? ; MPRINT(DTCHK): else leap = 0 ; MPRINT(DTCHK): * regular year ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (leap and dy>29) then good=0; MPRINT(DTCHK): * >29 days in leap yr? ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if ((not leap) and dy>28) then good=0; MPRINT(DTCHK): * >28 days in regular yr? ; MPRINT(DTCHK): end; MPRINT(DTCHK): * February ; MPRINT(DTCHK): else do ; MPRINT(DTCHK): * some other month? ; MPRINT(DTCHK): * too many days? ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): if (dy>dpm(mo)) then good=0; MPRINT(DTCHK): * too many days? ; MPRINT(DTCHK): * if (&dy>30 and (&mo=9 or &mo=4 or &mo=6 or &mo=11)) then good=0; MPRINT(DTCHK): end; MPRINT(DTCHK): * some other month ; MPRINT(DTCHK): end; MPRINT(DTCHK): * all integers ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (not good) then put 'ERROR BAD DATE ' _N_= ' ' yr= ' ' mo= ' ' dy= ; MLOGIC(DTCHK): Ending execution. 10621 %put "end " &sysdate= &systime= ; SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 "end " 21JUL07= 16:32= 10622 10623 run; ERROR BAD DATE _N_=65184 yr=. mo=. dy=. ERROR BAD DATE _N_=97355 yr=. mo=. dy=. ERROR BAD DATE _N_=225824 yr=. mo=. dy=. ERROR BAD DATE _N_=312857 yr=. mo=. dy=. ERROR BAD DATE _N_=331639 yr=. mo=. dy=. ERROR BAD DATE _N_=355268 yr=. mo=. dy=. ERROR BAD DATE _N_=359226 yr=. mo=. dy=. ERROR BAD DATE _N_=477907 yr=. mo=. dy=. ERROR BAD DATE _N_=823713 yr=. mo=. dy=. ERROR BAD DATE _N_=943009 yr=. mo=. dy=. NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 10 at 2:101 10 at 2:170 10 at 2:239 10 at 5:34 10 at 5:102 10 at 5:179 10 at 6:6 NOTE: There were 1000000 observations read from the data set WORK.MYDATASET. NOTE: DATA statement used (Total process time): real time 0.85 seconds cpu time 0.81 seconds 10624 *--------------------------------------------; 10625 * racedtck.sas Daniel Brockman 070721 race dtchk ; 10626 10627 options ls=80 symbolgen mprint mlogic ; 10628 10629 %let dir=C:/b/SAS-X405.5 ; 10630 %let subdir=&dir/sub ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 10631 %let datadir=&dir/data ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 10632 10633 libname mydata "&datadir" ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data NOTE: Libref MYDATA was successfully assigned as follows: Engine: V9 Physical Name: C:\b\SAS-X405.5\data 10634 10635 %include "&subdir/dtchk.sas" ; SYMBOLGEN: Macro variable SUBDIR resolves to C:/b/SAS-X405.5/sub 10818 10819 10820 data mydataset ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data 10821 infile "&datadir\megadate.txt"; * a set of dates ; 10822 input yr mo dy ; 10823 10824 run; NOTE: The infile "C:/b/SAS-X405.5/data\megadate.txt" is: File Name=C:\b\SAS-X405.5\data\megadate.txt, RECFM=V,LRECL=256 NOTE: 1000000 records were read from the infile "C:/b/SAS-X405.5/data\megadate.txt". The minimum record length was 5. The maximum record length was 10. NOTE: The data set WORK.MYDATASET has 1000000 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 3.70 seconds cpu time 1.97 seconds SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 10825 10826 %put "start " &sysdate= &systime= ; "start " 21JUL07= 16:32= 10827 %dtchk(mydataset,yr,mo,dy); MLOGIC(DTCHK): Beginning execution. MLOGIC(DTCHK): Parameter ISET has value mydataset MLOGIC(DTCHK): Parameter YR has value yr MLOGIC(DTCHK): Parameter MO has value mo MLOGIC(DTCHK): Parameter DY has value dy MPRINT(DTCHK): data _NULL_ ; SYMBOLGEN: Macro variable ISET resolves to mydataset MPRINT(DTCHK): set mydataset ; MPRINT(DTCHK): * number of days in each month of non-leap year ; MPRINT(DTCHK): * days per month ; MPRINT(DTCHK): a1=31; MPRINT(DTCHK): a2=28 ; MPRINT(DTCHK): a3=31 ; MPRINT(DTCHK): a4=30 ; MPRINT(DTCHK): a5=31 ; MPRINT(DTCHK): a6=30 ; MPRINT(DTCHK): a7=31 ; MPRINT(DTCHK): a8=31 ; MPRINT(DTCHK): a9=30 ; MPRINT(DTCHK): a10=31 ; MPRINT(DTCHK): a11=30 ; MPRINT(DTCHK): a12=31 ; MPRINT(DTCHK): array dpm(12) a1-a12; MPRINT(DTCHK): good=1; MPRINT(DTCHK): * starting assumption: date is good ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (dy ne int(dy)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo ne int(mo)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (yr ne int(yr)) then good=0; MPRINT(DTCHK): * yr not an integer? ; MPRINT(DTCHK): else do; MPRINT(DTCHK): * all integers ? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<100) then do; MPRINT(DTCHK): * 2 digit year? ; MPRINT(DTCHK): tyyyy = year(today()); MPRINT(DTCHK): * this year ; MPRINT(DTCHK): tcc = int(tyyyy/100) ; MPRINT(DTCHK): * this century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): tccyr = tcc*100 + yr ; MPRINT(DTCHK): * this year if yr is in this century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tccyr - tyyyy > 50) then tcc=tcc-1 ; MPRINT(DTCHK): * yr must be prev century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tyyyy - tccyr >=50) then tcc=tcc+1 ; MPRINT(DTCHK): * yr must be next century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): yr = tcc*100 + yr ; MPRINT(DTCHK): * we will work with this year number ; MPRINT(DTCHK): end ; MPRINT(DTCHK): * 2 digit year ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<1 or yr>9999) then good=0; MPRINT(DTCHK): * yr out of range?; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo<1 or mo>12) then good=0; MPRINT(DTCHK): * mo out of range?; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if (dy<1 or dy>31) then good=0; MPRINT(DTCHK): * dy out of range?; SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo = 2) then do; MPRINT(DTCHK): * February?? ; MPRINT(DTCHK): * discover whether leap year ; MPRINT(DTCHK): leap=0 ; MPRINT(DTCHK): * assume not a leap year; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (mod(yr,400)=0) then leap=1; MPRINT(DTCHK): * yr divides by 400? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,100)=0) then leap = 0 ; MPRINT(DTCHK): * century yr? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,4)=0) then leap=1 ; MPRINT(DTCHK): * yr divides by 4? ; MPRINT(DTCHK): else leap = 0 ; MPRINT(DTCHK): * regular year ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (leap and dy>29) then good=0; MPRINT(DTCHK): * >29 days in leap yr? ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if ((not leap) and dy>28) then good=0; MPRINT(DTCHK): * >28 days in regular yr? ; MPRINT(DTCHK): end; MPRINT(DTCHK): * February ; MPRINT(DTCHK): else do ; MPRINT(DTCHK): * some other month? ; MPRINT(DTCHK): * too many days? ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): if (dy>dpm(mo)) then good=0; MPRINT(DTCHK): * too many days? ; MPRINT(DTCHK): * if (&dy>30 and (&mo=9 or &mo=4 or &mo=6 or &mo=11)) then good=0; MPRINT(DTCHK): end; MPRINT(DTCHK): * some other month ; MPRINT(DTCHK): end; MPRINT(DTCHK): * all integers ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (not good) then put 'ERROR BAD DATE ' _N_= ' ' yr= ' ' mo= ' ' dy= ; MLOGIC(DTCHK): Ending execution. 10828 %put "end " &sysdate= &systime= ; SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 "end " 21JUL07= 16:32= 10829 10830 run; ERROR BAD DATE _N_=65184 yr=. mo=. dy=. ERROR BAD DATE _N_=97355 yr=. mo=. dy=. ERROR BAD DATE _N_=225824 yr=. mo=. dy=. ERROR BAD DATE _N_=312857 yr=. mo=. dy=. ERROR BAD DATE _N_=331639 yr=. mo=. dy=. ERROR BAD DATE _N_=355268 yr=. mo=. dy=. ERROR BAD DATE _N_=359226 yr=. mo=. dy=. ERROR BAD DATE _N_=477907 yr=. mo=. dy=. ERROR BAD DATE _N_=823713 yr=. mo=. dy=. ERROR BAD DATE _N_=943009 yr=. mo=. dy=. NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 10 at 2:101 10 at 2:170 10 at 2:239 10 at 5:34 10 at 5:102 10 at 5:179 10 at 6:6 NOTE: There were 1000000 observations read from the data set WORK.MYDATASET. NOTE: DATA statement used (Total process time): real time 0.87 seconds cpu time 0.82 seconds 10831 *--------------------------------------------; 10832 * racedtck.sas Daniel Brockman 070721 race dtchk ; 10833 10834 options ls=80 symbolgen mprint mlogic ; 10835 10836 %let dir=C:/b/SAS-X405.5 ; 10837 %let subdir=&dir/sub ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 10838 %let datadir=&dir/data ; SYMBOLGEN: Macro variable DIR resolves to C:/b/SAS-X405.5 10839 10840 libname mydata "&datadir" ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data NOTE: Libref MYDATA was successfully assigned as follows: Engine: V9 Physical Name: C:\b\SAS-X405.5\data 10841 10842 %include "&subdir/dtchk.sas" ; SYMBOLGEN: Macro variable SUBDIR resolves to C:/b/SAS-X405.5/sub 11025 11026 11027 data mydataset ; SYMBOLGEN: Macro variable DATADIR resolves to C:/b/SAS-X405.5/data 11028 infile "&datadir\megadate.txt"; * a set of dates ; 11029 input yr mo dy ; 11030 11031 run; NOTE: The infile "C:/b/SAS-X405.5/data\megadate.txt" is: File Name=C:\b\SAS-X405.5\data\megadate.txt, RECFM=V,LRECL=256 NOTE: 1000000 records were read from the infile "C:/b/SAS-X405.5/data\megadate.txt". The minimum record length was 5. The maximum record length was 10. NOTE: The data set WORK.MYDATASET has 1000000 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 3.14 seconds cpu time 2.00 seconds SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 11032 11033 %put "start " &sysdate= &systime= ; "start " 21JUL07= 16:32= 11034 %dtchk(mydataset,yr,mo,dy); MLOGIC(DTCHK): Beginning execution. MLOGIC(DTCHK): Parameter ISET has value mydataset MLOGIC(DTCHK): Parameter YR has value yr MLOGIC(DTCHK): Parameter MO has value mo MLOGIC(DTCHK): Parameter DY has value dy MPRINT(DTCHK): data _NULL_ ; SYMBOLGEN: Macro variable ISET resolves to mydataset MPRINT(DTCHK): set mydataset ; MPRINT(DTCHK): * number of days in each month of non-leap year ; MPRINT(DTCHK): * days per month ; MPRINT(DTCHK): a1=31; MPRINT(DTCHK): a2=28 ; MPRINT(DTCHK): a3=31 ; MPRINT(DTCHK): a4=30 ; MPRINT(DTCHK): a5=31 ; MPRINT(DTCHK): a6=30 ; MPRINT(DTCHK): a7=31 ; MPRINT(DTCHK): a8=31 ; MPRINT(DTCHK): a9=30 ; MPRINT(DTCHK): a10=31 ; MPRINT(DTCHK): a11=30 ; MPRINT(DTCHK): a12=31 ; MPRINT(DTCHK): array dpm(12) a1-a12; MPRINT(DTCHK): good=1; MPRINT(DTCHK): * starting assumption: date is good ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (dy ne int(dy)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo ne int(mo)) then good=0; MPRINT(DTCHK): * yr not an integer? ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (yr ne int(yr)) then good=0; MPRINT(DTCHK): * yr not an integer? ; MPRINT(DTCHK): else do; MPRINT(DTCHK): * all integers ? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<100) then do; MPRINT(DTCHK): * 2 digit year? ; MPRINT(DTCHK): tyyyy = year(today()); MPRINT(DTCHK): * this year ; MPRINT(DTCHK): tcc = int(tyyyy/100) ; MPRINT(DTCHK): * this century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): tccyr = tcc*100 + yr ; MPRINT(DTCHK): * this year if yr is in this century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tccyr - tyyyy > 50) then tcc=tcc-1 ; MPRINT(DTCHK): * yr must be prev century ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (tyyyy - tccyr >=50) then tcc=tcc+1 ; MPRINT(DTCHK): * yr must be next century ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): yr = tcc*100 + yr ; MPRINT(DTCHK): * we will work with this year number ; MPRINT(DTCHK): end ; MPRINT(DTCHK): * 2 digit year ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (yr<1 or yr>9999) then good=0; MPRINT(DTCHK): * yr out of range?; SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo<1 or mo>12) then good=0; MPRINT(DTCHK): * mo out of range?; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if (dy<1 or dy>31) then good=0; MPRINT(DTCHK): * dy out of range?; SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): else if (mo = 2) then do; MPRINT(DTCHK): * February?? ; MPRINT(DTCHK): * discover whether leap year ; MPRINT(DTCHK): leap=0 ; MPRINT(DTCHK): * assume not a leap year; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): if (mod(yr,400)=0) then leap=1; MPRINT(DTCHK): * yr divides by 400? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,100)=0) then leap = 0 ; MPRINT(DTCHK): * century yr? ; SYMBOLGEN: Macro variable YR resolves to yr MPRINT(DTCHK): else if (mod(yr,4)=0) then leap=1 ; MPRINT(DTCHK): * yr divides by 4? ; MPRINT(DTCHK): else leap = 0 ; MPRINT(DTCHK): * regular year ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (leap and dy>29) then good=0; MPRINT(DTCHK): * >29 days in leap yr? ; SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): else if ((not leap) and dy>28) then good=0; MPRINT(DTCHK): * >28 days in regular yr? ; MPRINT(DTCHK): end; MPRINT(DTCHK): * February ; MPRINT(DTCHK): else do ; MPRINT(DTCHK): * some other month? ; MPRINT(DTCHK): * too many days? ; SYMBOLGEN: Macro variable DY resolves to dy SYMBOLGEN: Macro variable MO resolves to mo MPRINT(DTCHK): if (dy>dpm(mo)) then good=0; MPRINT(DTCHK): * too many days? ; MPRINT(DTCHK): * if (&dy>30 and (&mo=9 or &mo=4 or &mo=6 or &mo=11)) then good=0; MPRINT(DTCHK): end; MPRINT(DTCHK): * some other month ; MPRINT(DTCHK): end; MPRINT(DTCHK): * all integers ; SYMBOLGEN: Macro variable YR resolves to yr SYMBOLGEN: Macro variable MO resolves to mo SYMBOLGEN: Macro variable DY resolves to dy MPRINT(DTCHK): if (not good) then put 'ERROR BAD DATE ' _N_= ' ' yr= ' ' mo= ' ' dy= ; MLOGIC(DTCHK): Ending execution. 11035 %put "end " &sysdate= &systime= ; SYMBOLGEN: Macro variable SYSDATE resolves to 21JUL07 SYMBOLGEN: Macro variable SYSTIME resolves to 16:32 "end " 21JUL07= 16:32= 11036 11037 run; ERROR BAD DATE _N_=65184 yr=. mo=. dy=. ERROR BAD DATE _N_=97355 yr=. mo=. dy=. ERROR BAD DATE _N_=225824 yr=. mo=. dy=. ERROR BAD DATE _N_=312857 yr=. mo=. dy=. ERROR BAD DATE _N_=331639 yr=. mo=. dy=. ERROR BAD DATE _N_=355268 yr=. mo=. dy=. ERROR BAD DATE _N_=359226 yr=. mo=. dy=. ERROR BAD DATE _N_=477907 yr=. mo=. dy=. ERROR BAD DATE _N_=823713 yr=. mo=. dy=. ERROR BAD DATE _N_=943009 yr=. mo=. dy=. NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 10 at 2:101 10 at 2:170 10 at 2:239 10 at 5:34 10 at 5:102 10 at 5:179 10 at 6:6 NOTE: There were 1000000 observations read from the data set WORK.MYDATASET. NOTE: DATA statement used (Total process time): real time 0.89 seconds cpu time 0.81 seconds 11038 *--------------------------------------------;