BookmarkSubscribeRSS Feed
MRuG
Calcite | Level 5

Hi everyone,

 

I ran into a problem when outputting parts of my multilevel analyses. More specifically, my degrees of freedom are shown as 12E3 instead of the actual numerical value. A colleague of mine gave me the following syntax to run which unfortunately did not work as I am still seeing the 12E3... I am using SAS 9.4.

Highly appreciate your help and tips!

 

Thank you 🙂

 

proc template;
define table Stat.Mixed.FTests;                                            
      notes "F-tests table";                                                  
      column Effect Label Var NumVar Margins ByLevel AtVar NumDF DenDF ChiSq  
         FValue ProbChiSq OrdChiSq ProbF OrdF ANOVANumDF ANOVADenDF           
         ANOVAFValue ANOVAProbF ANOVAProbFinf;                                
      header anovafheader;                                                    
      define Effect;                                                          
         header = "Effect";                                                   
         style = RowHeader;                                                   
         id;                                                                  
      end;                                                                    
      define Label;                                                           
         header = "Label";                                                    
         id;                                                                  
      end;                                                                    
      define Var;                                                             
         id;                                                                  
         generic;                                                             
      end;                                                                    
      define NumVar;                                                          
         translate _val_=._ into "";                                          
         just = l;                                                            
         id;                                                                  
         generic;                                                             
      end;                                                                    
      define Margins;                                                         
         header = "Margins";                                                  
      end;                                                                    
      define ByLevel;                                                         
         header = "By Level";                                                 
      end;                                                                    
      define AtVar;                                                           
         format = 6.2;                                                        
         generic;                                                             
      end;                                                                    
      define NumDF;                                                           
         header = "Num DF";                                                   
         format = 6.0;                                                        
      end;                                                                    
      define DenDF;                                                           
         header = "Den DF";                                                   
         format = best8.;                                                     
      end;                                                                    
      define ChiSq;                                                           
         header = ";Chi-Square";                                              
         translate _val_=.I into "  Infty";                                   
         format = 7.2;                                                        
      end;                                                                    
      define FValue;                                                          
         parent = Common.ANOVA.FValue;                                        
      end;                                                                    
      define ProbChiSq;                                                       
         width = 12;                                                          
         parent = Common.ProbChiSq;                                           
      end;                                                                    
      define OrdChiSq;                                                        
         header = "Ord ChiSq";                                                
         format = 6.4;                                                        
      end;                                                                    
      define ProbF;                                                           
         parent = Common.ANOVA.ProbF;                                         
      end;                                                                    
      define OrdF;                                                            
         header = "Ord F";                                                    
         format = 6.4;                                                        
      end;                                                                    
      define anovafheader;                                                    
         text "ANOVA F";                                                      
         space = 0;                                                           
         expand = "-";                                                        
         end = ANOVAProbFInf;                                                 
         start = ANOVANumDF;                                                  
         spill_margin;                                                        
      end;                                                                    
      define ANOVANumDF;                                                      
         header = "Num DF";                                                   
         format = best4.;                                                     
         glue = 2;                                                            
      end;                                                                    
      define ANOVADenDF;                                                      
         header = "Den DF";                                                   
         format = best4.;                                                     
         glue = 2;                                                            
      end;                                                                    
      define ANOVAFValue;                                                     
         header = "Value";                                                    
         glue = 2;                                                            
         parent = Common.ANOVA.FValue;                                        
      end;                                                                    
      define ANOVAProbF;                                                      
         header = "Pr > F(DDF)";                                              
         glue = 2;                                                            
         parent = Common.ANOVA.ProbF;                                         
      end;                                                                    
      define ANOVAProbFInf;                                                   
         header = "Pr > F(infty)";                                            
         glue = 2;                                                            
         parent = Common.ANOVA.ProbF;                                         
      end;                                                                    
      use_format_defaults;                                                    
   end;                                                                       
run;

13 REPLIES 13
Astounding
PROC Star

It's not clear which part of the troublesome report matches which part of the template, but the results give a clue.  Where you are using the best4 format as part of the template specifications, try increasing that to best5.  

MRuG
Calcite | Level 5
Unfortunately it didn't help! Thanks though
LinusH
Tourmaline | Level 20

You probably need to to expand the length of the format for those variable where you experience this. The scientific notation is used when SAS can't fit the full value.

Data never sleeps
MRuG
Calcite | Level 5
How do I do this exactly? Sorry I am still a newbie with SAS 🙂
LinusH
Tourmaline | Level 20

The first no in the format definition specifies the total display length:

So, instead of 6.0, try 10.0 (the 0 can be ommitted if you specify a no prior to the dot).

 

Data never sleeps
Shmuel
Garnet | Level 18

@MRuG wrote:  "my degrees of freedom are shown as 12E3 instead of the actual numerical value".

 

Your proc template defines format for various variables. Can you point which of them relate to degree of freedom?

 

Suppose it is NumDF then change the format from 6.0 into 9.3.

 

Check it.

MRuG
Calcite | Level 5

It's actually the DF that I get in the "solution for fixed effects" table. 

I added a 

define DF;
header = "DF";
format = 10.0;     (also tried it with 9.3)
end;

 

but neither had an effect. 

Shmuel
Garnet | Level 18

12E3 ia actually 12*10**3 = 12,000.

'12E3' holds 4 characters where 12,000 holds 6 characters.

 

Can you post few lines from the dataset used with the proc template.
maybe the variable name is not DF  and the default format is 4. ?

 

Please post the full code or the full log of your run.

 

 

MRuG
Calcite | Level 5

The data set consists of 12666 observations at level 1. We asked participants to report their behaviour during social interactions (multiple/day) for a period of 2 weeks. Specifically, we looked at the effect of drinking alcohol  on social behaviour.

In this example here, the effect of CALC (event-level drinking) on quarrelsome behaviour and how this relationship is influenced by Cheavy (between person-level drinking variable).

proc mixed data=in.finalALC METHOD=ML NOCLPRINT COVTEST ;
class id study;
model IMQURBEH = calc cheavy
calc*cheavy
/SOLUTION
DDFM=BETWITHIN htypE=1,3 ;  
RANDOM intercept cdrinkyn/type=un(1) sub=id ; 
repeated /type=ar(1) sub=id group=study; 
run;

The full code I used for the proc template is the following:

proc template;
define table Stat.Mixed.FTests;                                            
      notes "F-tests table";                                                  
      column Effect Label Var NumVar Margins ByLevel AtVar DF NumDF DenDF ChiSq  
         FValue ProbChiSq OrdChiSq ProbF OrdF ANOVANumDF ANOVADenDF           
         ANOVAFValue ANOVAProbF ANOVAProbFinf;                                
      header anovafheader;                                                    
      define Effect;                                                          
         header = "Effect";                                                   
         style = RowHeader;                                                   
         id;                                                                  
      end;                                                                    
      define Label;                                                           
         header = "Label";                                                    
         id;                                                                  
      end;                                                                    
      define Var;                                                             
         id;                                                                  
         generic;                                                             
      end;                                                                    
      define NumVar;                                                          
         translate _val_=._ into "";                                          
         just = l;                                                            
         id;                                                                  
         generic;                                                             
      end;                                                                    
      define Margins;                                                         
         header = "Margins";                                                  
      end;                                                                    
      define ByLevel;                                                         
         header = "By Level";                                                 
      end;                                                                    
      define AtVar;                                                           
         format = 6.2;                                                        
         generic;                                                             
      end;                                                                    
      define NumDF;                                                           
         header = "Num DF";                                                   
         format = 10.0;                                                        
      end; 
define DF;
header = "DF";
format = 10.0;
end; 
      define DenDF;                                                           
         header = "Den DF";                                                   
         format = best8.;                                                     
      end;                                                                    
      define ChiSq;                                                           
         header = ";Chi-Square";                                              
         translate _val_=.I into "  Infty";                                   
         format = 7.2;                                                        
      end;                                                                    
      define FValue;                                                          
         parent = Common.ANOVA.FValue;                                        
      end;                                                                    
      define ProbChiSq;                                                       
         width = 12;                                                          
         parent = Common.ProbChiSq;                                           
      end;                                                                    
      define OrdChiSq;                                                        
         header = "Ord ChiSq";                                                
         format = 6.4;                                                        
      end;                                                                    
      define ProbF;                                                           
         parent = Common.ANOVA.ProbF;                                         
      end;                                                                    
      define OrdF;                                                            
         header = "Ord F";                                                    
         format = 6.4;                                                        
      end;                                                                    
      define anovafheader;                                                    
         text "ANOVA F";                                                      
         space = 0;                                                           
         expand = "-";                                                        
         end = ANOVAProbFInf;                                                 
         start = ANOVANumDF;                                                  
         spill_margin;                                                        
      end;                                                                    
      define ANOVANumDF;                                                      
         header = "Num DF";                                                   
         format = best5.;                                                     
         glue = 2;                                                            
      end;                                                                    
      define ANOVADenDF;                                                      
         header = "Den DF";                                                   
         format = best5.;                                                     
         glue = 2;                                                            
      end;                                                                    
      define ANOVAFValue;                                                     
         header = "Value";                                                    
         glue = 2;                                                            
         parent = Common.ANOVA.FValue;                                        
      end;                                                                    
      define ANOVAProbF;                                                      
         header = "Pr > F(DDF)";                                              
         glue = 2;                                                            
         parent = Common.ANOVA.ProbF;                                         
      end;                                                                    
      define ANOVAProbFInf;                                                   
         header = "Pr > F(infty)";                                            
         glue = 2;                                                            
         parent = Common.ANOVA.ProbF;                                         
      end;                                                                    
      use_format_defaults;                                                    
   end;                                                                       
run;

Hope that makes things clearer / was what you were asking for. 

 

Shmuel
Garnet | Level 18

I'm not familiar with proc mixed and proc template.

I don't see the DF variable within the proc mixed. Is it a generated variable with this procedure?
I don't see, thouh there might be, connection between the two procedures.

 

Now that you have posted more code I hope someone else will be able to post a solution.

MRuG
Calcite | Level 5
Thanks anyway for your ideas! 🙂
Shmuel
Garnet | Level 18

I have found a similar (reverse) query to yours.

Compare proc mixed code.

maybe you'll come to a solution.

 

https://communities.sas.com/t5/SAS-Statistical-Procedures/Decimals-in-Degrees-of-freedom-proc-mixed/...

SuzanneDorinski
Lapis Lazuli | Level 10

Try running your code with the ODS TRACE ON; statement just before your PROC MIXED.  

 

The log will show that the "Solution for Fixed Effects" uses the Stat.Mixed.SolutionF template.  You can use PROC TEMPLATE to look at the source for the Stat.Mixed.SolutionF template.  The parent is the Stat.Mixed.tTests template.  DF uses the best4. format in the Stat.Mixed.tTests template. 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 13 replies
  • 2482 views
  • 1 like
  • 5 in conversation