DATA Step, Macro, Functions and more

Changing 12E3 output

Reply
Occasional Contributor
Posts: 6

Changing 12E3 output

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 Smiley Happy

 

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;

Super User
Posts: 5,069

Re: Changing 12E3 output

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.  

Occasional Contributor
Posts: 6

Re: Changing 12E3 output

Unfortunately it didn't help! Thanks though
Super User
Posts: 5,254

Re: Changing 12E3 output

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
Occasional Contributor
Posts: 6

Re: Changing 12E3 output

How do I do this exactly? Sorry I am still a newbie with SAS Smiley Happy
Super User
Posts: 5,254

Re: Changing 12E3 output

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
Trusted Advisor
Posts: 1,349

Re: Changing 12E3 output

@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.

Occasional Contributor
Posts: 6

Re: Changing 12E3 output

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. 

Trusted Advisor
Posts: 1,349

Re: Changing 12E3 output

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.

 

 

Occasional Contributor
Posts: 6

Re: Changing 12E3 output

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. 

 

Trusted Advisor
Posts: 1,349

Re: Changing 12E3 output

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.

Occasional Contributor
Posts: 6

Re: Changing 12E3 output

Thanks anyway for your ideas! Smiley Happy
Trusted Advisor
Posts: 1,349

Re: Changing 12E3 output

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/...

Contributor
Posts: 59

Re: Changing 12E3 output

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. 

Ask a Question
Discussion stats
  • 13 replies
  • 160 views
  • 1 like
  • 5 in conversation