BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

Please see examples of proc report with "computed" column.

 

I have some questions related to example1 /example2 please:

Why do we use "analysis mean"? It is not calculating mean here.It just show the values.

 

I have some questions related to example3 please:

Why the total row is not calculated here?

 

 

/*Example1*/
proc report  data=sashelp.class   NOWD;
Columns name sex age height weight ratio;
DEFINE name / display "Name" width=10;
DEFINE sex / display "Gender" width=6; 
DEFINE age / display "Age" width=4;  
DEFINE height / analysis mean  "Height" format=8.1;  
DEFINE weight / analysis mean "Weight" format=8.1;  
Define ratio /computed format=6.2;

compute ratio;
ratio=height.mean/weight.mean;
endcomp;
rbreak after/summarize;
run;

 
/*Example2*/
proc report  data=sashelp.class   NOWD;
Columns name sex age height weight ratio;
DEFINE name / display "Name" width=10;
DEFINE sex / display "Gender" width=6; 
DEFINE age / display "Age" width=4;  
DEFINE height / analysis mean  "Height" format=8.1;  
DEFINE weight / analysis mean "Weight" format=8.1;  
Define ratio /computed format=6.2;

compute ratio;
ratio=_C4_/_C5_;
endcomp;
rbreak after/summarize;
run;



/*Example3*/
proc report  data=sashelp.class   NOWD;
Columns name sex age height weight ratio;
DEFINE name / display "Name" width=10;
DEFINE sex / display "Gender" width=6; 
DEFINE age / display "Age" width=4;  
DEFINE height / display  "Height" format=8.1;  
DEFINE weight / display "Weight" format=8.1;  
Define ratio /computed format=6.2;

compute ratio;
ratio=_C4_/_C5_;
endcomp;

rbreak after/summarize;
run;
2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

q1) it is because you use the mean here:

height.mean/weight.mean;

q2) because mean is not calculated.

Ksharp
Super User

You are using " 

rbreak after/summarize;    

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1166 views
  • 0 likes
  • 3 in conversation