LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 27 Oct 2008 23:28:59 -0400
Reply-To:   Ya Huang <ya.huang@AMYLIN.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Ya Huang <ya.huang@AMYLIN.COM>
Subject:   Re: Coding help required.
Comments:   To: Arthur Tabachneck <art297@NETSCAPE.NET>
Content-Type:   text/plain; charset=ISO-8859-1

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


Back to: Top of message | Previous page | Main SAS-L page