- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
I want to calculate the mean of blood pressures in my dataset. I have a variables for each blood pressure (bp1, bp2,bp3 etc). It is variable how many blood pressure each participant have (they can have up to 20 or more).
data have;
input ID bp1 bp2 bp 3;
datalines;
1 145 120 125
2 130 . .
3 125 125
;
run;
data want;
input ID bp1 bp2 bp3 mean;
datalines;
1 145 120 125 130
2 130 . . 130
3 125 125 125
;
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If all the variables share a common prefix like in your sample data, you can do this
data have;
input ID bp1 bp2 bp3;
datalines;
1 145 120 125
2 130 . .
3 125 125 .
;
data want;
set have;
mean = mean(of bp:);
run;
Result:
ID bp1 bp2 bp3 mean 1 145 120 125 130 2 130 . . 130 3 125 125 . 125
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If all the variables share a common prefix like in your sample data, you can do this
data have;
input ID bp1 bp2 bp3;
datalines;
1 145 120 125
2 130 . .
3 125 125 .
;
data want;
set have;
mean = mean(of bp:);
run;
Result:
ID bp1 bp2 bp3 mean 1 145 120 125 130 2 130 . . 130 3 125 125 . 125
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The most straightforward way is to transpose your data so you have one row for each test.
Then you can use a standard procedure to calculate the mean (PROC SQL, MEANS etc).