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 (April 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 9 Apr 2008 02:11:17 +0000
Reply-To:   toby dunn <tobydunn@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   toby dunn <tobydunn@HOTMAIL.COM>
Subject:   Re: Simple LAG Data Step
Comments:   To: Tom White <tw2@mail.com>
In-Reply-To:   <20080408214143.DE783164293@ws1-4.us4.outblaze.com>
Content-Type:   text/plain; charset="iso-8859-1"

Data Need ( Drop = Cnt LastDate ) ; Length Diff $ 2 ; Set Have ; By PROV_ID ID ;

LastDate = Lag( MyDate ) ;

If Not First.ID Then Do ; If MyDate Ne LastDate Then Do ; Cnt + 1 ; Diff = CatS( 'N' , Cnt ) ; End ; Else Do ; Diff = '0' ; End ; End ; Run ;

Toby Dunn "Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch

"Be prepared. Luck is where preparation meets opportunity." Randy Pausch

---------------------------------------- > Date: Tue, 8 Apr 2008 16:41:43 -0500 > From: tw2@MAIL.COM > Subject: Simple LAG Data Step > To: SAS-L@LISTSERV.UGA.EDU > > Hi everyone, > > The following problem looks like a simple LAG issue. > It doesn't work for me when I do a BY PROV_ID. > > I wish to create the DIFF variable as shown below. > > Thank you. > T > > > > PROV_ID ID MYDATE > 01 111111111 24Feb2003 > 01 111111111 24Feb2003 > 01 111111111 24Feb2003 > 01 111111111 24Feb2003 > > 02 222222222 24Sep2004 > 02 333333333 07Sep2003 > > 03 444444444 10Jul2003 > 03 444444444 03May2004 > 03 444444444 07Dec2005 > > > PROV_ID ID MYDATE DIFF > 01 111111111 24Feb2003 . > 01 111111111 24Feb2003 0 > 01 111111111 24Feb2003 0 > 01 111111111 24Feb2003 0 > > 02 222222222 24Sep2004 . /* or 0 doesn't matter*/ > > 02 333333333 07Sep2003 . /* or 0 doesn't matter*/ > > 03 444444444 10Jul2003 . > 03 444444444 03May2004 N1 > 03 444444444 07Dec2005 N2 > > N1= 03May2004 - 10Jul2003 > N2= 07Dec2005 - 03May2004 > > > > -- > Want an e-mail address like mine? > Get a free e-mail account today at www.mail.com!

_________________________________________________________________ Use video conversation to talk face-to-face with Windows Live Messenger. http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_042008


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