Date: Fri, 9 Mar 2001 16:56:17 -0500
Reply-To: "Shilling, Brian [PRI]" <BShillin@PRIUS.JNJ.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Shilling, Brian [PRI]" <BShillin@PRIUS.JNJ.COM>
Subject: Re: Finding a gap in a date range
Content-Type: multipart/alternative;
How about something like this.....
data a
set a;
by acct_num;
if first.acct_num then prevdate = .; /* Reset the previous date when
the account number changes */
else prevdate = lag(start_date);
if (start_date - prevdate) > 1 then flag = 'YES';
run;
HTH
Brian
> -----Original Message-----
> From: Petruso Steven V [SMTP:svpetrus@NEWWESTENERGY.COM]
> Sent: Friday, March 09, 2001 4:49 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Finding a gap in a date range
>
> Hello all, anyone have any great suggestions on how to find a gap in a
> date
> range ? I've got a SAS table with millions of rows of account data
> including sas dates, I want to flag or identify those accounts (account#)
> that have a break in the sequential date range. These are formatted sas
> dates, so they are positive integers. Sample data:
>
>
> acct_num start_date
> ------------- --------------
> 1234567 01feb01
> 1234567 02feb01
> 1234567 03feb01
> 1234567 04feb01
> 1234567 20feb01
> 1234567 21feb01
> 1234567 22feb01
> .........
>
> This account # would be flagged because of the break between 04feb and
> 20feb.
>
> TIA
>
> Steve Petruso
> New West Energy
> svpetrus@newwestenergy.com
[text/html]
|