BookmarkSubscribeRSS Feed
rhaley1821
Obsidian | Level 7

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

A1111.111.19.09.0
B8315.315.37.07.0
O3015.515.511.011.0
W44915.515.57.67.6
 57315.415.47.87.8

 

I would appreciate any help!! 

 

Thanks so much

2 REPLIES 2
ballardw
Super User

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.

Cynthia_sas
SAS Super FREQ

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:

Cynthia_sas_0-1606847540173.png

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:

Cynthia_sas_0-1606850326883.png

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

sas-innovate-white.png

🚨 Early Bird Rate Extended!

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.

Register now!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 920 views
  • 1 like
  • 3 in conversation