Generate the windows for each possible PRE_FILL in 2005 and examine them:
do pre_fill = '01jan2005'd to '31dec2005'd;
do study_fill = '01jan2004'd to '31dec2006'd;
(day(pre_fill) > day(study_fill) );
if 0 le mon_diff le 6 then output;
format pre_fill study_fill date9.;
proc tabulate data=days;
table pre_fill, study_fill * ((min max)*f=date9. range*f=5.);
It appears that the windows are each 7 months, so you probably want to
change LE 6 to LT 6 or LE 5.
The other issue with this kind of problem is the effect of the varying
length of months. This is most noticeable for intervals which conclude near
the end of February. The table here shows you that the windows for July 29,
July 30, July 31, and August 1 all end on February 28. If that's OK, fine.
Otherwise the code will need modification.
On Tue, 20 Sep 2005 11:02:09 -0400, Dave Hapeman
> I want to make sure my thinking is correct. In a dataset I have two
>SAS date variables. I want to see if the one is within six months of the
>second. My code is this:
> mon_diff= intck('month',pre_fill,study_fill)-(day(pre_fill) > day
> if 0 le mon_diff le 6 then output;
> I wuld appreciate if the group would look at this to double check me.