Date: Sat, 9 Aug 2008 21:23:46 -0400
Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@NETSCAPE.NET>
Subject: Re: Arrays - help
Sam,
I think that you have already received answers to your question but, from
you last post, I'm really not sure.
Here is a slightly different way of doing the same thing. I don't know if
I have the desired boundaries defined correctly, but they can easily be
adjusted:
*use Muthia's sample data;
data have;
format time hhmm5.;
do ID = 1 to 3;
start = 30600 + ceil(ranuni(123) * 36000);
endtime = start + 85200;
do t = start to endtime by 1200;
time = mod(t,86400);
SysBp = 95 + ceil(ranuni(123) * 40);
output;
end;
end;
keep id time sysbp;
run;
data temp (drop= x y);
set have;
by id;
x=mod(put(mod( time, "24:00:00"t),hhmm2.),3);
y=lag(x);
if first.id then period=1;
else if x ne y and x eq 0 then period+1;
if put(mod( time, "24:00:00"t),hhmm2.) ge 18
or put(mod( time, "24:00:00"t),hhmm2.)le 5
then daynight=1;
else daynight=2;
run;
proc summary data=temp;
var SysBp;
class id daynight period;
output out=need (where=(_type_ ge 6)) mean=;
run;
proc sort data=need;
by id _type_ period;
run;
proc transpose data=need
out=want (where=(_name_ eq 'SysBp')
rename=(col1=dn2 col2=dn1
col3=period01 col4=periold02
col5=period03 col6=periold04
col6=period05 col7=periold06
col8=period07 col9=periold08
col10=period09 col11=periold10));
by id;
run;
HTH,
Art
--------
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