Hello,
I'm trying to calculate blood pressure means per subject over the course of multiple
blood pressure readings. Subjects can have a range of visits from few to many.
My data is organized as follows
PAT_ID | Date | Systolic | Diastolic | Meds |
1 | 2-Nov-22 | 155 | 85 | |
1 | 3-Nov-22 | 135 | 90 | |
1 | 5-Nov-22 | 145 | 77 | |
1 | 6-Nov-22 | 145 | 82 | |
2 | 7-Nov-22 | 158 | 98 | |
2 | 22-Apr-22 | 130 | 70 | |
2 | 22-May-22 | 140 | 80 | med 1 |
2 | 4-Oct-22 | 130 | 72 | |
2 | 11-Oct-22 | 142 | 65 | |
3 | 14-Oct-22 | 154 | 61 | |
3 | 18-Oct-22 | 145 | 70 | |
4 | 23-Oct-22 | 150 | 69 | |
4 | 30-Oct-22 | 144 | 71 | |
4 | 22-Apr-22 | 165 | 90 | med 2 |
4 | 22-Jun-22 | 160 | 80 | med 2 |
5 | 22-Aug-22 | . | . | med 3 |
5 | 4-Oct-22 | 128 | 93 | |
5 | 8-Oct-22 | 162 | 96 | |
5 | 9-Oct-22 | 158 | 96 | |
6 | 11-Oct-22 | 149 | 91 | |
6 | 14-Oct-22 | 154 | 86 |
I know some of my analysis will involve FIRST and LAST, but how do I calculate the mean per subject when the number of visits per subjects is not necessarily the same. I think I need to use an array here but need a little help getting started.
Thank you in advance for your help.
@joesmama wrote:
I'm trying to calculate blood pressure means per subject over the course of multiple
blood pressure readings. Subjects can have a range of visits from few to many.
I know some of my analysis will involve FIRST and LAST, but how do I calculate the mean per subject when the number of visits per subjects is not necessarily the same. I think I need to use an array here but need a little help getting started.
FIRST. and LAST. will work fine in this case, but for cases where you need to calculate statistics for a "group" (in this case a PAT_ID), I would use PROC MEANS
proc means data=have;
class pat_id;
var systolic diastolic;
run;
@joesmama wrote:
I'm trying to calculate blood pressure means per subject over the course of multiple
blood pressure readings. Subjects can have a range of visits from few to many.
I know some of my analysis will involve FIRST and LAST, but how do I calculate the mean per subject when the number of visits per subjects is not necessarily the same. I think I need to use an array here but need a little help getting started.
FIRST. and LAST. will work fine in this case, but for cases where you need to calculate statistics for a "group" (in this case a PAT_ID), I would use PROC MEANS
proc means data=have;
class pat_id;
var systolic diastolic;
run;
Thank you Paige. I was definitely over thinking it.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.