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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.