Date: Sat, 16 Aug 2003 22:06:53 -0700
Reply-To: "Schwarz, Barry A" <barry.a.schwarz@BOEING.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Schwarz, Barry A" <barry.a.schwarz@BOEING.COM>
Subject: Re: finding correct timeline
Content-Type: text/plain; charset="us-ascii"
Let's assume that end_dt >= start_dt for each record. Let's also assume
that if one class starts the day after the previous class ends, you want
them to be treated as if they actually overlapped. Try something like
data old;
INPUT class type $ start_dt :DATE7. end_dt :DATE7.;
CARDS;
481 B 04FEB02 19JUL02
481 B 03SEP02 18NOV02
481 B 03FEB03 23APR03
771 B 05AUG02 11MAR03
771 B 04NOV02 09JAN03
771 B 31MAR03 08JUL03
923 B 01JUL02 03APR03
1069 B 28DEC01 18SEP02
1069 B 09AUG02 21MAY03
1069 B 28MAR03 23JUL03
1417 B 22JAN02 21OCT02
1417 B 31MAY02 10DEC02
1417 B 01MAY03 18JUL03
3451 C 18FEB03 15AUG03
3451 B 09JUN03 07JUL03
3461 B 31JAN03 07AUG03
3481 C 28FEB03 15AUG03
;
RUN;
PROC SORT DATA=xx;
BY class start_dt;
RUN;
DATA new (DROP = start_dt end_dt);
RETAIN start_new end_new;
SET old;
IF FIRST.class THEN
DO;
start_new = start_dt;
end_new = end_dt;
END;
IF start_dt <= end_new+1 & end_dt > end_new THEN
end_new = end_dt;
IF start_dt > end_new+1 | LAST.class THEN
DO;
OUTPUT;
start_new = start_dt;
end_new = end_dt;
END;
RUN;
-----Original Message-----
From: Don [mailto:donmazais@HOTMAIL.COM]
Sent: Friday, August 15, 2003 3:28 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: finding correct timeline
Before I go to weekend recess I have another one that is over my SAS
head at this point:
Data set:
CLASS type start_dt end_dt
481 B 04FEB02 19JUL02
481 B 03SEP02 18NOV02
481 B 03FEB03 23APR03
771 B 05AUG02 11MAR03
771 B 04NOV02 09JAN03
771 B 31MAR03 08JUL03
923 B 01JUL02 03APR03
1069 B 28DEC01 18SEP02
1069 B 09AUG02 21MAY03
1069 B 28MAR03 23JUL03
1417 B 22JAN02 21OCT02
1417 B 31MAY02 10DEC02
1417 B 01MAY03 18JUL03
3451 C 18FEB03 15AUG03
3451 B 09JUN03 07JUL03
3461 B 31JAN03 07AUG03
3481 C 28FEB03 15AUG03
Need to figure out the time line for the CLASS. Time portion that
overlap need to be subtracted (type is not important)
example:
Class 481 would be (19JUL02-04FEB02) +(18NOV02 - 03SEP02) + (23APR03 -
03FEB03)
Class 771 would be (11MAR03 - 05AUG02) + (03APR03-01JUL02) (you will
notice that middle one is dropped because it is within the first ones
range)
Class 1069 would be (09AUG02-28DEC01)+( 21MAY03-09AUG02)+(
23JUL03-21MAY03) (here end dates overlap with the start dates thus I
need to adjust for that)
Those are the most obvious possibilities. Does anyone have an idea how
to solve something like this in SAS. (Pardon my inexperience if this is
easy).
Have a nice weekend!
Don