Hi,
I have a dataset called wide1 with the following id variables which represent each individual. Here is a sample of my data below.
How would I find the average post-intervention umaqs score for each patient? umaqs0 is measure before intervention, umaqs6- umaqs26 is measure post intervention.
I want using the code below but am not sure if this is right.
proc means data=wide1;
var umaqs6 umaqs12 umaqs26;
run;
14789 | 2 | umaqs | 10 | 10 | 15 | 15 |
15170 | 2 | umaqs | 16 | 20 | 20 | 20 |
15611 | 1 | umaqs | 10 | 20 | 18 | 22 |
15697 | 1 | umaqs | 10 | 10 | 10 | 11 |
15844 | 1 | umaqs | 21 | 26 | 26 | 27 |
15846 | 2 | umaqs | 26 | 29 | 28 | 24 |
If what you want is to compute the average across several variables for each row of your data set, then you can use the MEAN function in the DATA step. For example, these statements compute the average across the umaqs6-umaqs26 variables for each row and record the average in a new variable called AVG_UMAQS:
data new;
set your-dataset-name;
avg_umaqs=mean(of umaqs2-umaqs26);
run;
From now on, data should be provided as working SAS data step code (instructions) and not as screen captures.
It is not clear to me which column is the patient, as you have not provided a variable named patient. Honestly, it is hard to align the data you do show with your description.
I want using the code below but am not sure if this is right.
proc means data=wide1;
var umaqs6 umaqs12 umaqs26;
run;
Any time you are not sure if your code is right, my recommendation is that you actually try the code and see.
If what you want is to compute the average across several variables for each row of your data set, then you can use the MEAN function in the DATA step. For example, these statements compute the average across the umaqs6-umaqs26 variables for each row and record the average in a new variable called AVG_UMAQS:
data new;
set your-dataset-name;
avg_umaqs=mean(of umaqs2-umaqs26);
run;
@PaigeMiller Thank you for your observation.
This is the sample data. I have more than 100 rows. How do I find the average post-intervention umaqs score for each patient? It is the "each patient" that's getting me confused.
data wide1;
input ID$ Group umaqs0 umaqs6 umaqs12 umaqs26;
datalines;
14789 2 10 10 15 15
15170 2 16 20 20 20
15611 1 10 20 18 22
15697 1 10 10 10 11
15844 1 21 26 26 27
;run;
@CathyVI wrote:
@PaigeMiller Thank you for your observation.
This is the sample data. I have more than 100 rows. How do I find the average post-intervention umaqs score for each patient? It is the "each patient" that's getting me confused.
data wide1;
input ID$ Group umaqs0 umaqs6 umaqs12 umaqs26;
datalines;
14789 2 10 10 15 15
15170 2 16 20 20 20
15611 1 10 20 18 22
15697 1 10 10 10 11
15844 1 21 26 26 27
;run;
You still haven't made it clear what "each patient" means here. Are we trying to average numbers across rows? (If so then I think @StatDave is on the right track) Or are you not trying to average across rows, and you want something else?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.