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;
q1) it is because you use the mean here:
height.mean/weight.mean;
q2) because mean is not calculated.
You are using "
rbreak after/summarize;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.