Date: Tue, 25 Jul 2000 16:35:55 -0400
Reply-To: "T. Flannery" <flannery_t@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "T. Flannery" <flannery_t@HOTMAIL.COM>
Subject: datdif function help
Content-Type: multipart/alternative;
SAS-Lers,
I have to make a comparison between event 'X', which is a date value and the difference in time between each of 137 months. The start time for the months is Dec, 1988 and the end time is April, 2000. (Its actually 12/31/1988 and 04/31/2000, not 12/01/1988 as I have it coded below, but I can't figure out a way to get the end of months correct--any help on this appreciated, but using the first of the month is OK for suggestions)
So, I need to compare event 'X' to each of these dates and return a difference in time. For example, if 'X' for obs 1 was '01dec1988'd the difference in dates for the first round would be zero.
What I'm trying *not* to do is create 137 columns for each specific date (e.g., DATE1=column of 12/01/1988 -- DATE137= column of 04/01/2000) for each comparison because there are millions of records. Essentially, coding this as an array would something like:
array _dates(*) date1--date137; * Static columns;
array _dif(*) ddif1--ddif137;
do i=1 to dim(_dates);
_ddif(i)=datedif(_dates(i), x, 'act/act');
end;
Is there a way to create a multi-dimensional array that would allow me to compare the event to row1 col1 (r1c1) ... then r1c2 etc. This would keep the comparison table small as opposed to the method described above (which I could actually do). However, doing something different than above is beyond my coding ability/experience.
Any help/suggestions appreciated (I'm guessing the folks at the CDC do this stuff all the time).
T. Flannery
Here are my dates:
data a;
do i=1 to 12;
month=i;
do j=1988 to 2000;
yr=j;
day=1;
output;
end;
end;
drop i j;
run;
proc sort data=a;
by yr month;
run;
data b(KEEP=xdate);set a;
if month<12 and yr=1988 then delete;
if month >4 and yr=2000 then delete;
yra=put(yr, 4.);
mntha=put(month, z2.);
dy=put(day, z2.);
xdate=mdy(mntha,dy,yra);
format xdate mmyys.;
run;
[text/html]