BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Multipla99
Quartz | Level 8

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?

 

proc report
data= SASHELP.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 - Weight;
  endcomp;
    compute before;
        Sex='TOTALT';
    endcomp;
    rbreak before/ SUMMARIZE;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Kathryn_SAS
SAS Employee

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;

View solution in original post

2 REPLIES 2
Kathryn_SAS
SAS Employee

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;
Tom
Super User Tom
Super User

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;

Tom_0-1763049024597.png

 

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore 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
  • 916 views
  • 4 likes
  • 3 in conversation