From: Al on
All:

I Have the data in the following format ..i need to create a variable
avg .. .. The vital are systolic and diastolic ..more than one reading
for systolic and diastolic were taken at each visit .. i need to find
the average of all the readings taken at each visit per each vital
sign

Any suggestions

Thanks
Al

patno lbread test vis res avg
11 sys1 sys 1 120 125
11 sys2 sys 1 130 125
11 sys1 sys 2 150 123.3
11 sys2 sys 2 100 123.3
11 sys3 sys 2 120 123.3
22 Dia1 Dia 1 100 100
22 Dia1 Dia 1 100 100
From: Amar Mundankar on
On Mar 31, 8:55 pm, Al <ali6...(a)gmail.com> wrote:
> All:
>
> I Have the data in the following format ..i need to create a variable
> avg .. .. The vital are systolic and diastolic ..more than one reading
> for systolic and diastolic were taken  at each visit .. i need to find
> the average of all the readings taken at each visit per each vital
> sign
>
> Any suggestions
>
> Thanks
> Al
>
> patno lbread  test vis res  avg
> 11    sys1    sys      1  120  125
> 11    sys2    sys      1  130  125
> 11    sys1    sys      2   150  123.3
> 11    sys2    sys      2  100  123.3
> 11    sys3    sys      2  120  123.3
> 22    Dia1    Dia      1  100  100
> 22    Dia1    Dia      1  100  100

Hi AI,
Try this.
data have;
input patno lbread $ test $ vis res ;
cards;
11 sys1 sys 1 120
11 sys2 sys 1 130
11 sys1 sys 2 150
11 sys2 sys 2 100
11 sys3 sys 2 120
22 Dia1 Dia 1 100
22 Dia1 Dia 1 100
;
proc sql;
select * , (sum(res)/count(test)) as avg from have
group by patno,vis;
quit;

Hope this helps you.

Regards,
Amar Mundankar.