Can someone please help me and explain why I get the following messages when I run the code below?
NOTE: Variable Weight is uninitialized.
NOTE: Variable Height is uninitialized.
And why the column DIFF is empty in the result table?
You need to refer to the variables with their .statistic extension. Also to prevent the label for Sex from being truncated at the Break line, you need to change the length.
Revised code:
data class;
length sex $8;
set sashelp.class;
run;
proc report data= CLASS;
column Sex Height Weight Diff;
define Sex / group 'Sex'
style(column)={just= l };
define Height / sum 'Height'
style(column)= {just= l };
define Weight / sum 'Weight'
style(column)= {just= l };
define Diff / computed 'Diff'
style(column)= {just= r};
compute Diff;
Diff = Height.sum - Weight.sum;
endcomp;
compute before;
Sex='TOTALT';
endcomp;
rbreak before/ SUMMARIZE;
run;
You need to refer to the variables with their .statistic extension. Also to prevent the label for Sex from being truncated at the Break line, you need to change the length.
Revised code:
data class;
length sex $8;
set sashelp.class;
run;
proc report data= CLASS;
column Sex Height Weight Diff;
define Sex / group 'Sex'
style(column)={just= l };
define Height / sum 'Height'
style(column)= {just= l };
define Weight / sum 'Weight'
style(column)= {just= l };
define Diff / computed 'Diff'
style(column)= {just= r};
compute Diff;
Diff = Height.sum - Weight.sum;
endcomp;
compute before;
Sex='TOTALT';
endcomp;
rbreak before/ SUMMARIZE;
run;
PROC REPORT can create the longer variable.
proc report data= sashelp.CLASS;
column Sex Sex2 Height Weight Diff;
define Sex / group noprint;
define Sex2 / group computed 'Sex' style(column)={just= l };
define Height / sum 'Height' style(column)= {just= l };
define Weight / sum 'Weight' style(column)= {just= l };
define Diff / computed 'Diff' style(column)= {just= r};
compute sex2 / character length=8;
sex2=sex;
endcomp;
compute Diff;
Diff = Height.sum - Weight.sum;
endcomp;
compute before;
Sex2='TOTAL';
endcomp;
rbreak before/ SUMMARIZE;
run;
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →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.
Ready to level-up your skills? Choose your own adventure.