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

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;

Obs ID Group _NAME_ umaqs0 umaqs6 umaqs12 umaqs26123456
147892umaqs10101515
151702umaqs16202020
156111umaqs10201822
156971umaqs10101011
158441umaqs21262627
158462umaqs26292824
1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

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;

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
StatDave
SAS Super FREQ

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;

CathyVI
Pyrite | Level 9

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

PaigeMiller
Diamond | Level 26

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

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 4 replies
  • 415 views
  • 0 likes
  • 3 in conversation