Hi all,
I have been working on this problem for quite a while and cannot seem to figure out how to break up my proc report statements so as to display mean and std simultaneously for a numeric variable.
The table I wish to produce is:
| Average Pressures | ||||
| Systolic | Diastolic | |||
Race Code | N | MEAN | STD | MEAN | STD |
Asian | 11 | 117.1 | 11.1 | 69.1 | 9.0 |
Black | 83 | 123.3 | 15.3 | 74.0 | 7.0 |
Other Race | 30 | 115.2 | 15.5 | 69.8 | 11.0 |
White | 449 | 120.8 | 15.5 | 70.0 | 7.6 |
| 573 | 120.8 | 15.4 | 70.6 | 7.8 |
My current code will not allow me to simultaneously display MEAN and STD:
PROC REPORT
DATA = hypanal.hypanalysis1 Split="/"
MISSING;
COLUMN RaceCd N ("Average Pressures"
("Systolic" SBP SBP) ("Diastolic" DBP DBP));
DEFINE RaceCd /group;
Define N / "N";
DEFINE SBP / ANALYSIS MEAN STD format=4.1 "MEAN" "STD";
DEFINE DBP / ANALYSIS MEAN STD format=4.1 "MEAN" "STD";
RBREAK AFTER / SUMMARIZE;
RUN;
the result is close, but only displays STD instead of STDs and MEANS:
Average Pressures Systolic DiastolicRace Code N MEANSTD MEANSTD MEANSTD MEANSTD
A | 11 | 11.1 | 11.1 | 9.0 | 9.0 |
B | 83 | 15.3 | 15.3 | 7.0 | 7.0 |
O | 30 | 15.5 | 15.5 | 11.0 | 11.0 |
W | 449 | 15.5 | 15.5 | 7.6 | 7.6 |
573 | 15.4 | 15.4 | 7.8 | 7.8 |
I would appreciate any help!!
Thanks so much
You can only request one statistic or apply one column heading per Define statement.
One way that may do what you want is to use alias for the variable to request separate statistics. To do that you use "variable = aliasname" in the Columns statement and then use the Define with the aliasname
Something like:
PROC REPORT DATA = hypanal.hypanalysis1 Split="/" MISSING; COLUMN RaceCd N ("Pressures" ("Systolic" SBP=sysmean SBP=sysstd) ("Diastolic" DBP=dysmean DBP=dysstd)); DEFINE RaceCd /group; Define N / "N"; DEFINE sysmean / ANALYSIS MEAN format=4.1 "MEAN" ; DEFINE sysstd / ANALYSIS STD format=4.1 "STD"; DEFINE dysmean / ANALYSIS MEAN STD format=4.1 "MEAN"; DEFINE dysstd / ANALYSIS MEAN STD format=4.1 "STD"; RBREAK AFTER / SUMMARIZE; RUN;
I'm not sure that the column headings you are placing on the column statement with the parentheses will do exactly as you want but the define statements should work. You may want to include more decimals in the STD to be a bit more meaningful.
Hi:
A PROC REPORT use of alias as @ballardw suggested is the way to get what you want. Using SASHELP.HEART, which has DIASTOLIC and SYSTOLIC as variables, this is what it looks like, including headers:
I used BP_STATUS as the GROUP variable, but that was the major difference.
And, you can accomplish the same results using the comma operator with an analysis variable (essentially "crossing" or "nesting" statistics under an analysis variable, as shown in the code below:
And although that simplifies the COLUMN statement, it also has the limitation that MEAN and STD each get only 1 DEFINE statement, so you couldn't easily have one label for MEAN under SYSTOLIC and a separate label for MEAN under DIASTOLIC, for example.
Cynthia
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.