|
|
Comparing start and stop dates
Hello,
I have a problem where i have a popuation taking drugs and there are
multiple start and stop dates for each drug. I need to create a any
drug use start and stop date,
drg1_stdt1 = 1/1/2010, drg1_enddt1=2/1/2010, drg2_stdt1=1/15/2010,
drg2_stdt1=2/15/2010'
For above scenario i would have a anyuse_stdt1=1/1/2010 and
anyuse_enddt1=2/15/2010. The second start date for anyuse
(anyuse_stdt2) would look at all the start dates in all five drugs and
pick the stdt closest to anyuse_enddt1
Since the above drugs have multiple start and stop dates, I would end
up with multiple start and stop dates for anyuse as well.
drg1 for example could have 5 start and stop dates,
drg1_stdt1 - drg1_stdt5, drg1_enddt1 - drg1_enddt5
I was thinking in terms of a multidimentional array, but I am finding
it difficult to conceptualize. Any help with this would be greatly
appreciated.
|
|
0
|
|
|
|
Reply
|
VG
|
8/11/2010 6:55:10 PM |
|
On Aug 11, 11:55=A0am, VG <vamshidarg...@gmail.com> wrote:
> Hello,
>
> I have a problem where i have a popuation taking =A0drugs and there are
> multiple start and stop dates for each drug. I need to create a any
> drug use start and stop date,
>
> drg1_stdt1 =3D 1/1/2010, drg1_enddt1=3D2/1/2010, drg2_stdt1=3D1/15/2010,
> drg2_stdt1=3D2/15/2010'
>
> For above scenario i would have a anyuse_stdt1=3D1/1/2010 and
> anyuse_enddt1=3D2/15/2010. The second start date for anyuse
> (anyuse_stdt2) would look at all the start dates in all five drugs and
> pick the stdt closest to anyuse_enddt1
>
> Since the above drugs have multiple start and stop dates, I would end
> up with multiple start and stop dates for anyuse as well.
>
> drg1 for example could have 5 start and stop dates,
> drg1_stdt1 - drg1_stdt5, drg1_enddt1 - drg1_enddt5
>
> I was thinking in terms of a multidimentional array, but I am finding
> it difficult to conceptualize. Any help with this would be greatly
> appreciated.
What's your data currently like right now?
|
|
0
|
|
|
|
Reply
|
fkhurshed (247)
|
8/11/2010 8:39:17 PM
|
|
Hi Reeza
THe data was single record per individual. I was overthinking it by
putting all the start stop dates in one line. I found something that
Ian Whitlock had written to handle this issue which required me to
transpose the data to multiple records per individual with each line
containing one start and stop date. Code below is from Ian posted in
the uga listserv
data q ( keep = id curstart curend ) ;
retain curstart curend ;
format curstart curend startdate enddate date9. ;
set w ;
by id ;
if first.id then
do ;
curstart = startdate ;
curend = enddate ;
end ;
if enddate < startdate then error ;
if enddate > curend
and curstart <= startdate <= curend + 1 then
curend = enddate ;
if startdate > curend then
do ;
output ;
curstart = startdate ;
curend = enddate ;
end ;
if last.id then
do ;
output ;
end ;
run ;
|
|
0
|
|
|
|
Reply
|
VG
|
8/12/2010 1:57:13 PM
|
|
On Aug 12, 8:57=A0am, VG <vamshidarg...@gmail.com> wrote:
> Hi Reeza
>
> THe data was single record per individual. I was overthinking it by
> putting all the start stop dates in one line. I found something that
> Ian Whitlock had written to handle this issue which required me to
> transpose the data to multiple records per individual with each line
> containing one start and stop date. Code below is from Ian posted in
> the uga listserv
>
> data q ( keep =3D id curstart curend ) ;
> =A0 =A0retain curstart curend ;
> =A0 =A0format curstart curend startdate enddate date9. ;
> =A0 =A0set w ;
> =A0 =A0by id ;
> =A0 =A0if first.id then
> =A0 =A0do ;
> =A0 =A0 =A0 curstart =3D startdate ;
> =A0 =A0 =A0 curend =3D enddate ;
> =A0 =A0end ;
>
> =A0 =A0if enddate < startdate then error ;
>
> =A0 =A0if enddate > curend
> =A0 =A0 =A0 and curstart <=3D startdate <=3D curend + 1 then
> =A0 =A0 =A0 curend =3D enddate ;
>
> =A0 =A0if startdate > curend then
> =A0 =A0do ;
> =A0 =A0 =A0 output ;
> =A0 =A0 =A0 curstart =3D startdate ;
> =A0 =A0 =A0 curend =3D enddate ;
> =A0 =A0end ;
>
> =A0 =A0if last.id then
> =A0 =A0do ;
> =A0 =A0 =A0 output ;
> =A0 =A0end ;
> run ;
Show example of data you start with that represents all scenarios.
Then show example of the data arrangement you want to end up with.
Details.
|
|
0
|
|
|
|
Reply
|
datanull (3058)
|
8/12/2010 2:16:39 PM
|
|
|
3 Replies
263 Views
(page loaded in 0.049 seconds)
|
|
|
|
|
|
|
|
|