Date: Wed, 6 Aug 2008 17:08:40 -0400
Reply-To: Kevin Viel <citam.sasl@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Kevin Viel <citam.sasl@GMAIL.COM>
Subject: Re: Arrays - help
On Wed, 6 Aug 2008 11:49:54 -0400, sam <samygeb@GMAIL.COM> wrote:
>Hi all
>
>I am wrestling with this problem, I am sure some body could help me. I am
>posting the question again. I have a 24 hours blood pressure data with
>measurments taken every 20 minutes. The data looks some thing like this: I
>have more than 1000 subjects.
>
>ID SystBp Time
>01 140 8:30 (starting time)
>01 135 8:50
>01 136 9:10
>. . .
>. . .
>. . .
>01 135 8:30 (ending time- the next day)
>
>02 137 9:30 (starting time)
>02 125 9:50
>. . .
>. . .
>. . .
>02 135 9:30 (ending time- the next day)
>
>03 122 14:50 (start time)
>03 130 15:10
>03 134 15:30
>. . .
>. . .
>. . .
>03 137 15:50 (ending time- the next day)
>
>I want to derive variables 24 hour mean systbp, mean systbp every 3 hours
>and mean daytime systbp and nighttime bp in such away that the newly
>derived dataset is one observation pre subject.
>
>The desired output
>
>Id 24hmean systbp3 systbp6 systbp9... systbp24 daytimebp nighttimebp
>01 127.5 130.5 . . . . .
>02 135.8 125.6 . . . . .
>03 140.9 124.7 . . . . .
>
>I tried to use arrays to solve the problem but I have no luck so far.
>
>Thank you
>sam
Hmmm. Why not post your attempts? It is one way to get criticism.
We do not have the advantage of knowing whether TIME is set for each
subject.
/* UNTESTED */
data one ;
array BP_ ( 24 ) ;
array BP_3_ ( 8 ) ;
i_3 = 0 ;
do _n_ = 1 by 1 until ( last.ID ) ;
set BP_24 ;
by ID ;
BP_( _n_ ) = systbp ;
if mod( time - "8:30"t , 3 ) = 0 then
do ;
i_3 + 1 ;
BP_3_( i_3 ) = systbp ;
end ;
end ;
do _n_ = 1 to _n_ ;
_24_sum + BP_( _n_ ) ;
end ;
_24_mean = _24_sum / ( _n_ - 1 ) ;
do _n_ = 1 to dim( BP_3_ ) ;
_3_sum + BP_3_( _n_ ) ;
end ;
_3_mean = _3_sum / ( _n_ - 1 ) ;
run ;
HTH,
Kevin