how to get a mean of a variable for each subject in a repaet data set

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 82
Accepted Solution

how to get a mean of a variable for each subject in a repaet data set


Dear all,

here is my data set:

A B  C

1 3 120

1 6 110

1 9 140

2 3 110

2 6 105

3 3 118

4 3 160

4 6 170

4 9 180

4 12 110

A is ID, B is month, C is systolic blood pressure. I want to average blood pressure for each ID. Is there a simple way?

Thanks,

Xinjian


Accepted Solutions
Solution
‎07-13-2015 03:42 PM
Trusted Advisor
Posts: 1,203

Re: how to get a mean of a variable for each subject in a repaet data set

proc sql;

select a as id,avg(c) as average_blood_pressure format=8.2 from have

group by a;

quit;

View solution in original post


All Replies
Frequent Contributor
Posts: 128

Re: how to get a mean of a variable for each subject in a repaet data set

I would use the MEANS procedure with a class variable:

proc means data=have mean nway noprint;

var C;

class A;

output out=want (drop=_TYPE_ _FREQ_)

mean=Avg_Blood_Pressure;

run;

Hope this helps!

Solution
‎07-13-2015 03:42 PM
Trusted Advisor
Posts: 1,203

Re: how to get a mean of a variable for each subject in a repaet data set

proc sql;

select a as id,avg(c) as average_blood_pressure format=8.2 from have

group by a;

quit;

Frequent Contributor
Posts: 82

Re: how to get a mean of a variable for each subject in a repaet data set

I really appreciate your help.

Also, thank you, dcruik, for your quick response, and different version to solve this problem.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 241 views
  • 0 likes
  • 3 in conversation