|
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
>
|