BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
joesmama
Obsidian | Level 7

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.  

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@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;

 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

@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;

 

--
Paige Miller
joesmama
Obsidian | Level 7

Thank you Paige. I was definitely over thinking it. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 388 views
  • 0 likes
  • 2 in conversation