Dear All;
This is what i have
data have;
input pat meds $ stdt spdt;
datalines;
111 ABC 1 .
111 CBF 1 140
111 DFS 141 170
111 NAT 65 .
111 MAN 160 165
111 MAA 6 223
;
run;
range for week 20 (1-143),week 24 (1-171),week 23 (1-227) and the
rules are
if stdt = 1 and spdt = . then it should be counted under week20 ,
week24 and week32
if stdt has started at week 20 and kept on progressing it has stopped
(spdt) he counted under week20,week24 and week32
if stdt has started at week 20 and stopped at week 24 it has to be
counted under week20,week24
and so on
i know i am being very crude in explaining the issue here ,so here is
the graphical presentation
pat med week20
week24 week32
(1-143)
(1-171) (1-227)
111 ABC
(1)--------------------------------------------------------------------------------
>
111 CBF (1)------------------->(140)
111 DFS (141)------>170
111 NAT
(65)--------------------------------------------------------------------------
>
111 MAN (160)------
>(165)
111 MAA
(6)----------------------------------------------------------------
>(223)
ideally ,output should like
pat week20 week24 week32
111 5 4 3
Thanks in advance
Al
|
|
0
|
|
|
|
Reply
|
ali6058 (166)
|
7/16/2010 7:28:50 PM |
|
On Jul 16, 3:28=A0pm, Al <ali6...@gmail.com> wrote:
> Dear All;
>
> This is what i have
>
> data have;
> =A0 input pat meds $ stdt spdt;
>
> =A0 datalines;
> 111 ABC 1 .
> 111 CBF 1 140
> 111 DFS 141 170
> 111 NAT 65 .
> 111 MAN 160 165
> 111 MAA 6 223
> ;
> run;
>
> range for week 20 (1-143),week 24 (1-171),week 23 (1-227) and the
> rules are
>
> if stdt =3D 1 and spdt =3D . then it should be counted under week20 ,
> week24 and week32
>
> if stdt has started at week 20 and kept on progressing it has stopped
> (spdt) he counted under week20,week24 and week32
>
> if stdt has started at week 20 and stopped at week 24 it has to be
> counted under week20,week24
>
> and so on
>
> i know i am being very crude in explaining the issue here ,so here is
> the graphical presentation
>
> pat =A0 =A0 med =A0 =A0 =A0week20
> week24 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 week32
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (1-143)
> (1-171) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (1-227)
>
> 111 =A0 =A0 ABC
> (1)----------------------------------------------------------------------=
--=AD--------
>
> 111 =A0 =A0 CBF =A0 =A0 =A0(1)------------------->(140)
> 111 =A0 =A0 DFS =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 (141)------>170
> 111 =A0 =A0 NAT
> (65)---------------------------------------------------------------------=
--=AD---
>
> 111 =A0 =A0 MAN =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(160)------>(165)
>
> 111 =A0 =A0 MAA
> (6)----------------------------------------------------------------
>
> >(223)
>
> ideally ,output should like
>
> pat =A0 week20 =A0week24 =A0week32
> 111 =A0 =A05 =A0 =A0 =A0 =A04 =A0 =A0 =A0 3
>
> Thanks in advance
> Al
Al:
The explanation was pretty vague. Here is some sample code that
matches your sample output/
----------
data have;
input pat meds $ stdt spdt;
datalines;
111 ABC 1 .
111 CBF 1 140
111 DFS 141 170
111 NAT 65 .
111 MAN 160 165
111 MAA 6 223
;
run;
data activity;
set have;
if STDT > 0;
GUARD =3D MIN (SPDT,1e10);
if STDT <=3D GUARD;
if ( STDT < 1 or 1 <=3D STDT <=3D 143 ) and (GUARD > 143 or 1 <=3D
GUARD <=3D 143) then c143 =3D 1;
if ( STDT < 144 or 144 <=3D STDT <=3D 171 ) and (GUARD > 171 or 144 <=3D
GUARD <=3D 171) and c143 then c171 =3D 1;
if ( STDT < 171 or 171 <=3D STDT <=3D 227 ) and (GUARD > 227 or 172 <=3D
GUARD <=3D 227) and c171 then c227 =3D 1;
run;
----------
Richard A. DeVenezia
http://www.devenezia.com
|
|
0
|
|
|
|
Reply
|
rdevenezia (99)
|
7/19/2010 6:24:00 PM
|
|