I am trying to create this output in my PROC REPORT:
Blood Pressure Summaries by Race
| 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 |
*The format of this shows up kinda off. The systolic and diastolic labels are supposed to be over the Mean and STD variables.
So far I have this code:
options fmtsearch = (HypTabs.HypFormats WORK LIBRARY);
proc format;
value $RaceCd
' ' = 'Unknown'
'A' = 'Asian'
'B' = 'Black'
'O' = 'Other Race'
'W' = 'White'
other = 'Unexpected Value';
run;
title 1 "Blood Pressure Summaries By Race";
proc report
data = HypAnl.HypPrimAnl
nowindows
split = '/';
column RaceCd N ("Average Pressures" SBP DBP);
define RaceCd / groip 'Race Code';
define SBP / analysis mean format = 5.1 'MEAN' analysis std format =4.1 'STD';
define DBP / analysis mean format = 4.1 'MEAN' analysis std format =4.1 'STD';
rebreak after / summarize;
format RaceCd $RaceCd.;
run;
The issue is getting the MEAN and STD variables split up in the table, because now only one is showing up. Any ideas?
Hi:
Your DEFINE statements are incorrect. Since you did not post data, I used SASHELP.HEART which has diastolic and systolic measurements, but there is no ethnicity variable in SASHELP.HEART, so I used CHOL_STATUS for categories/grouping. I imagine that you want something like this:
which I produced with this code (I added an overall summary line just in case you wanted something like that too):
title 'Using SASHELP.HEART';
proc report data=sashelp.heart;
where agechddiag gt 65;
column chol_status N
('Average Pressures' Diastolic,(mean std) Systolic,(mean std));
define chol_status / group;
define N / 'Count';
define Diastolic / analysis 'Diastolic';
define Systolic / analysis 'Systolic';
define Mean / 'Mean';
define std / 'Std';
rbreak after / summarize;
run;
PROC REPORT allows you to "cross" multiple statistics "under" an analysis variable as I show above. So when the COLUMN statement has this:
Diastolic,(mean std) or
Systolic,(mean std)
then I am asking for the MEAN and STD statistics to be calculated using the variable named DIASTOLIC and then again, calculated using the variable SYSTOLIC.
Hope this gives you a better idea of how to get what you want with PROC REPORT.
cynthia
Hi:
Your DEFINE statements are incorrect. Since you did not post data, I used SASHELP.HEART which has diastolic and systolic measurements, but there is no ethnicity variable in SASHELP.HEART, so I used CHOL_STATUS for categories/grouping. I imagine that you want something like this:
which I produced with this code (I added an overall summary line just in case you wanted something like that too):
title 'Using SASHELP.HEART';
proc report data=sashelp.heart;
where agechddiag gt 65;
column chol_status N
('Average Pressures' Diastolic,(mean std) Systolic,(mean std));
define chol_status / group;
define N / 'Count';
define Diastolic / analysis 'Diastolic';
define Systolic / analysis 'Systolic';
define Mean / 'Mean';
define std / 'Std';
rbreak after / summarize;
run;
PROC REPORT allows you to "cross" multiple statistics "under" an analysis variable as I show above. So when the COLUMN statement has this:
Diastolic,(mean std) or
Systolic,(mean std)
then I am asking for the MEAN and STD statistics to be calculated using the variable named DIASTOLIC and then again, calculated using the variable SYSTOLIC.
Hope this gives you a better idea of how to get what you want with PROC REPORT.
cynthia
I tried this code based off of what you gave me, but it is not working. I get the error message listed below.
Figured out my problem. Was just referencing the variables wrong.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.