SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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