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 (August 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 20 Aug 2007 09:11:32 -0400
Reply-To:     Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Subject:      Re: finding date difference
In-Reply-To:  <1187611319.721426.74330@x35g2000prf.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

Murugesh,

Try this. You can do it without using LAG function. Assumed that custnum = 107262 is valid.

data given; input custnum invnum $ invdate mmddyy8.; cards; 1004159 I000698 01/16/07 1004159 I000699 02/17/07 1004159 I000700 02/23/07 1004159 I000701 03/06/07 1004159 I000702 05/11/07 1014885 I000703 01/25/07 1014885 I000704 02/04/07 1014885 I000705 02/16/07 1014885 I000706 02/25/07 1014885 I000707 04/05/07 1020600 I000709 01/06/07 1020600 I000710 01/15/07 1020600 I000711 01/26/07 1020600 I000712 03/29/07 1020600 I000713 05/13/07 1031528 I000715 01/27/07 1040996 I000716 02/23/07 1040996 I000717 03/04/07 1040996 I000718 03/09/07 1040996 I000719 03/13/07 1040996 I000720 04/07/07 1040996 I000721 05/07/07 1047016 I000723 01/11/07 1047016 I000724 04/03/07 1047016 I000725 04/30/07 1047016 I000726 05/01/07 1061037 I000727 01/30/07 1061037 I000728 02/07/07 1061037 I000729 03/13/07 1061037 I000730 05/17/07 107262 I000051 04/29/07 ; run;

proc sort data = given; by custnum; run; data wanted; do until(last.custnum); set given; by custnum; diff = invdate - prev; output; prev = invdate; end; drop prev; run;

Regards,

Muthia Kachirayan


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