|
Art,
I think 'conseceutive month' literally means the var 'consecmths'
in the sample data. In other word, he want to find six records
in a row that has the var consecmths from 1 to 6.
Here is my sql solution:
data xx;
input SrvDte :date. DaysGap ConsecMths;
format srvdte date.;
cards;
10AUG2007 0 1
26SEP2007 47 1
04OCT2007 8 2
05OCT2007 1 3
06NOV2007 32 1
29NOV2007 23 2
11DEC2007 12 3
27DEC2007 16 4
24JAN2008 28 5
04FEB2008 11 6
18MAR2008 43 1
02MAY2008 45 1
03JUL2008 62 1
;
data xx;
set xx;
if consecmths=1 then grp+1;
run;
proc sql;
select *
from xx
group by grp
having count(*)=6
order by srvdte,consecmths
;
SrvDte DaysGap ConsecMths grp
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ
06NOV07 32 1 3
29NOV07 23 2 3
11DEC07 12 3 3
27DEC07 16 4 3
24JAN08 28 5 3
04FEB08 11 6 3
On Mon, 27 Oct 2008 22:58:31 -0400, Arthur Tabachneck <art297@NETSCAPE.NET>
wrote:
>Phil,
>
>Define what you consider to be a consecutive month. You say that only 6
>rows should be included from your example. Why only 6 and which ones?
>
>Art
>---------
>On Mon, 27 Oct 2008 18:31:34 -0700, Phil <phillip.anderra@GMAIL.COM> wrote:
>
>>Hullo nice group,
>>
>>I need to extract *only* the rows below where the row is part of a
>>sequence of >= six Consecutive Months. eg. From the dataset below
>>there'd be a total of six rows output. It's proving too hard for me so
>>if anyone could help it'd be appreciated.
>>
>>
>>PIN SrvDte DaysGap ConsecMths
>>2999128 10AUG2007 0 1
>> 26SEP2007 47 1
>> 04OCT2007 8 2
>> 05OCT2007 1 3
>> 06NOV2007 32 1
>> 29NOV2007 23 2
>> 11DEC2007 12 3
>> 27DEC2007 16 4
>> 24JAN2008 28 5
>> 04FEB2008 11 6
>> 18MAR2008 43 1
>> 02MAY2008 45 1
>> 03JUL2008 62 1
>>
>>
>>
>>cheers
>>Phil
|