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 (December 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 19 Dec 2008 12:34:17 -0600
Reply-To:   "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "./ ADD NAME=Data _null_," <iebupdte@GMAIL.COM>
Subject:   Re: overlapping dates issue
Comments:   To: "middela.sreekanth@gmail.com" <middela.sreekanth@gmail.com>
In-Reply-To:   <d706ace6-9c67-4c01-bf3c-0cb99296131e@m4g2000vbp.googlegroups.com>
Content-Type:   text/plain; charset=ISO-8859-1

This will be good enough unless you have lots of data. Not sure how much that would be.

The technique expands the data and the summarized by day to get total dose per day then collapses it back to date range.

data temp ; input subjid $ cmstdt:date9. cmendt:date9. dose; format cm: date9.; cards; 1000 10JAN2006 30Jan2006 10 1000 15JAN2006 20Jan2006 15 1000 25JAN2006 20FEB2006 5 1000 02FEB2006 26FEB2006 25 ;;;; run; data expandV / view=expandV; set temp; do date = cmstdt to cmendt; output; end; format date date9.; run; proc summary data=expandV nway; class subjid date; output out=work.dose sum(dose)=; run; proc summary data=dose nway; by subjid dose notsorted; output out=work.doseRange(drop=_type_ _freq_) idgroup(min(date) out(date)=cmstdt) idgroup(max(date) out(date)=cmendt) ; run; proc print; run;

On 12/19/08, middela.sreekanth@gmail.com <middela.sreekanth@gmail.com> wrote: > Hi SAS users - > > I ran into a problem while working on an analysis dataset, which I > couldn't solve . > I need some help from you in the following ovelapping dates case . > > If there is an overlapping of the doses, then I need to add the doses > for the overlapping periods and create > individual reacords for non overlapping and overlapping dates. The > example below might help my requirement. > > > > data temp ; > input subjid $ cmstdt date9. cmendt date9. dose ; > cards ; > 1000 10JAN2006 30Jan2006 10 > 1000 15JAN2006 20Jan2006 15 > 1000 25JAN2006 20FEB2006 5 > 1000 02FEB2006 26FEB2006 25 > ; > run ; > > > > *** The output datasets should have the following records *** > 1000 10JAN2006 14Jan2006 10 > 1000 15JAN2006 20JAN2006 25(10+15) > 1000 21JAN2006 24Jan2006 10 > 1000 25JAN2006 30JAN2006 15(10+5) > 1000 31JAN2006 01FEB2006 5 > 1000 02FEB2006 20FEB2006 30(5+25) > 1000 21FEB2006 26FEB2006 25 > > > I really appreciate your help . > > Thanks, > Sree >


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