BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Zerg
Calcite | Level 5

Hello,

 

I want to set the default rounding for parameter estimates and standard errors to the nearest 4th digit (in the html output) for all SAS regression procedures (such as proc reg, proc glm, proc surveyreg). I figured out how to do this on p-values (set to 2th digit):

 

proc template;
define column Common.PValue;
notes "Default p-value column";
just = r;
format = pvalue9.2;
end;
run;

But I can't do the same thing on parameter estimates and standard errors with the following codes:

proc template;
define column Common.ParameterEstimates.Estimate;
notes "Default estimates column";
just = r;
format = d9.4;
end;
run;

Is there a way to achieve what I want? I appreciate any help. Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
SuzanneDorinski
Lapis Lazuli | Level 10

The D9.4 format is not the same as the 9.4 format.  I modified an example from The BEST D formats that you have ever seen! to show the difference.

 

data test_d_format;
	x1=100 / 3;
	x2=x1 ** 2;
	x3=1 / x1;
	x4=x1 / 10;
	x5=12;
	format x1-x5 D9.4;
	put (x1-x5) (/);
run;

proc print data=test_d_format;
	title 'Using D9.4 format';
run;

data test_format;
	x1=100 / 3;
	x2=x1 ** 2;
	x3=1 / x1;
	x4=x1 / 10;
	x5=12;
	format x1-x5 9.4;
	put (x1-x5) (/);
run;

proc print data=test_format;
	title 'Using 9.4 format';
run;

D9.4 is not the same as 9.4 format!D9.4 is not the same as 9.4 format!

Redefining Common.ParameterEstimates.Estimate probably isn't sufficient. 

 

I looked at the source for Stat.SurveyReg.ParameterEstimates and noticed that while it uses Common.ParameterEstimates.Estimate, it also uses the CHOOSE_FORMAT option (see below), which probably overrides the format you specify for Common.ParameterEstimates.Estimate.  

 

    define Estimate;
       choose_format = min_max;
       parent = Common.ParameterEstimates.Estimate;
    end;

I also looked at the source for Stat.REG.SelParmEst, and it doesn't show Common.ParameterEstimatesEstimate as the parent for Estimate.

 

    define Estimate;
       header = ";Parameter;Estimate";
       format = d11.3;
    end;

View solution in original post

2 REPLIES 2
SuzanneDorinski
Lapis Lazuli | Level 10

The D9.4 format is not the same as the 9.4 format.  I modified an example from The BEST D formats that you have ever seen! to show the difference.

 

data test_d_format;
	x1=100 / 3;
	x2=x1 ** 2;
	x3=1 / x1;
	x4=x1 / 10;
	x5=12;
	format x1-x5 D9.4;
	put (x1-x5) (/);
run;

proc print data=test_d_format;
	title 'Using D9.4 format';
run;

data test_format;
	x1=100 / 3;
	x2=x1 ** 2;
	x3=1 / x1;
	x4=x1 / 10;
	x5=12;
	format x1-x5 9.4;
	put (x1-x5) (/);
run;

proc print data=test_format;
	title 'Using 9.4 format';
run;

D9.4 is not the same as 9.4 format!D9.4 is not the same as 9.4 format!

Redefining Common.ParameterEstimates.Estimate probably isn't sufficient. 

 

I looked at the source for Stat.SurveyReg.ParameterEstimates and noticed that while it uses Common.ParameterEstimates.Estimate, it also uses the CHOOSE_FORMAT option (see below), which probably overrides the format you specify for Common.ParameterEstimates.Estimate.  

 

    define Estimate;
       choose_format = min_max;
       parent = Common.ParameterEstimates.Estimate;
    end;

I also looked at the source for Stat.REG.SelParmEst, and it doesn't show Common.ParameterEstimatesEstimate as the parent for Estimate.

 

    define Estimate;
       header = ";Parameter;Estimate";
       format = d11.3;
    end;
Zerg
Calcite | Level 5

Thank you for the clarification on the difference between d9.4 and 9.4 format. It is helpful.

 

Interestingly, I checked the ParameterEstimates file of proc reg from Sashelp.Tmplstat_en, which governs the format of proc reg output. Here is what I found:

 

proc template;                                                                
   define table Stat.Reg.ParameterEstimates / store = SASHELP.TMPLSTAT_EN;    
      notes "Parameter estimate table";                                       
      dynamic dynglue confidence widthMax _hccMethod;                         
      column Variable Label DF Estimate StdErr tValue Probt BetaWarning       
         HCStdErr HCCMethod HCTValue HCProbt TypeISS TypeIISS StandardizedEst 
         SemiCorrTypeI CumRSquare FValueI ProbFI SeqFValueI SeqProbFI         
         SqPartCorrTypeI SemiCorrTypeII FValueII ProbFII SqPartCorrTypeII     
         Tolerance VarianceInflation LowerCL UpperCL HCLowerCl HCUpperCL;     
      header h1 clhead typeIhead typeISeqHead typeIIhead HCHead HCclhead;     
                                                                              
      define h1;                                                              
         text "Parameter Estimates";                                          
         space = 1;                                                           
         spill_margin;                                                        
      end;                                                                    
                                                                              
      define clhead;                                                          
         text confidence BEST8. %nrstr("%% Confidence Limits");               
         end = UpperCL;                                                       
         start = LowerCL;                                                     
      end;                                                                    
                                                                              
      define HCclhead;                                                        
         text "Heteroscedasticity Consistent " confidence BEST8.              
            %nrstr("%% Confidence Limits");                                   
         width = 30;                                                          
         end = HCUpperCL;                                                     
         start = HCLowerCL;                                                   
         spill_margin;                                                        
      end;                                                                    
                                                                              
      define HCHead;                                                          
         text "Heteroscedasticity Consistent";                                
         expand = "-";                                                        
         end = HCProbt;                                                       
         start = HCStdErr;                                                    
      end;                                                                    
                                                                              
      define typeIhead;                                                       
         text "Type I";                                                       
         expand = "-";                                                        
         end = ProbFI;                                                        
         start = FValueI;                                                     
      end;                                                                    
                                                                              
      define typeISeqhead;                                                    
         text "Sequential Type I";                                            
         expand = "-";                                                        
         end = SeqProbFI;                                                     
         start = SeqFValueI;                                                  
      end;                                                                    
                                                                              
      define typeIIhead;                                                      
         text "Type II";                                                      
         expand = "-";                                                        
         end = ProbFII;                                                       
         start = FValueII;                                                    
      end;                                                                    
                                                                              
      define Variable;                                                        
         header = "Variable";                                                 
         style = RowHeader;                                                   
         id;                                                                  
      end;                                                                    
                                                                              
      define DF;                                                              
         parent = Common.ParameterEstimates.DF;                               
         id;                                                                  
      end;                                                                    
                                                                              
      define Estimate;                                                        
         header = ";Parameter;Estimate";                                      
         format = d11.3;                                                      
         parent = Common.ParameterEstimates.Estimate;                         
      end;                                                                    
                                                                              
      define StdErr;                                                          
         header = ";Standard;Error";                                          
         format = d11.3;                                                      
         parent = Common.ParameterEstimates.StdErr;                           
      end;                                                                    
                                                                              
      define tValue;                                                          
         parent = Stat.Reg.tValue;                                            
      end;                                                                    
                                                                              
      define Probt;                                                           
         glue = dynglue;                                                      
         parent = Stat.REG.Probt;                                             
      end;                                                                    
                                                                              
      define BetaWarning;                                                     
         translate                                                            
            _val_=0 into "",                                                  
            _val_=1 into "*";                                                 
         format = 1.0;                                                        
         pre_merge;                                                           
      end;                                                                    
                                                                              
      define HCStdErr;                                                        
         header = ";Standard;Error";                                          
         format = d11.3;                                                      
         parent = Common.ParameterEstimates.StdErr;                           
      end;                                                                    
                                                                              
      define HCCMethod;                                                       
         header = "HCCMethod";                                                
         print = OFF;                                                         
      end;                                                                    
                                                                              
      define HCTValue;                                                        
         parent = Stat.Reg.tValue;                                            
      end;                                                                    
                                                                              
      define HCProbt;                                                         
         glue = dynglue;                                                      
         parent = Stat.REG.Probt;                                             
      end;                                                                    
                                                                              
      define TypeISS;                                                         
         header = ";Type I SS";                                               
         format = d11.3;                                                      
      end;                                                                    
                                                                              
      define TypeIISS;                                                        
         header = ";Type II SS";                                              
         format = d11.3;                                                      
      end;                                                                    
                                                                              
      define StandardizedEst;                                                 
         header = ";Standardized;Estimate";                                   
         format = d11.3;                                                      
         parent = Common.ParameterEstimates.StandardizedEst;                  
      end;                                                                    
                                                                              
      define SemiCorrTypeI;                                                   
         header = ";Squared;Semi-partial;Corr Type I";                        
         format = d11.3;                                                      
      end;                                                                    
                                                                              
      define CumRSquare;                                                      
         header = ";Cumulative;R-Square";                                     
         format = d11.3;                                                      
      end;                                                                    
                                                                              
      define FValueI;                                                         
         glue = 10;                                                           
         parent = Stat.REG.FValue;                                            
      end;                                                                    
                                                                              
      define ProbFI;                                                          
         parent = Stat.REG.ProbF;                                             
      end;                                                                    
                                                                              
      define SeqFValueI;                                                      
         glue = 10;                                                           
         parent = Stat.REG.FValue;                                            
      end;                                                                    
                                                                              
      define SeqProbFI;                                                       
         parent = Stat.REG.ProbF;                                             
      end;                                                                    
                                                                              
      define SqPartCorrTypeI;                                                 
         header = ";Squared;Partial;Corr Type I";                             
         format = d11.3;                                                      
      end;                                                                    
                                                                              
      define SemiCorrTypeII;                                                  
         header = ";Squared;Semi-partial;Corr Type II";                       
         format = d11.3;                                                      
      end;                                                                    
                                                                              
      define FValueII;                                                        
         glue = 10;                                                           
         parent = Stat.REG.FValue;                                            
      end;                                                                    
                                                                              
      define ProbFII;                                                         
         parent = Stat.REG.ProbF;                                             
      end;                                                                    
                                                                              
      define SqPartCorrTypeII;                                                
         header = ";Squared;Partial;Corr Type II";                            
         format = d11.3;                                                      
      end;                                                                    
                                                                              
      define Tolerance;                                                       
         header = "Tolerance";                                                
         format = d11.3;                                                      
      end;                                                                    
                                                                              
      define VarianceInflation;                                               
         header = ";Variance;Inflation";                                      
         format = d11.3;                                                      
      end;                                                                    
                                                                              
      define LowerCL;                                                         
         format = d11.3;                                                      
         glue = 10;                                                           
         print_headers = OFF;                                                 
      end;                                                                    
                                                                              
      define UpperCL;                                                         
         format = d11.3;                                                      
         print_headers = OFF;                                                 
      end;                                                                    
                                                                              
      define HCLowerCL;                                                       
         format = d11.3;                                                      
         glue = 10;                                                           
         print_headers = OFF;                                                 
      end;                                                                    
                                                                              
      define HCUpperCL;                                                       
         format = d11.3;                                                      
         print_headers = OFF;                                                 
      end;                                                                    
                                                                              
      define Label;                                                           
         width = widthMax;                                                    
         parent = Common.ParameterEstimates.Label;                            
         maximize;                                                            
      end;                                                                    
      required_space = 5;                                                     
      use_name;                                                               
   end;                                                                       
run;      

 

 

As you can see, this section

 

   define Estimate;                                                        
         header = ";Parameter;Estimate";                                      
         format = d11.3;                                                      
         parent = Common.ParameterEstimates.Estimate;                         
      end;     

does specify that the parent of Estimate is Common.ParameterEstimates.Estimate. The more interesting thing is that the format of estimate is set to d11.3, but the output I get from proc reg gives me parameter estimates rounded to the nearest 5th decimal point. I guess locating the file Common.ParameterEstimates.Estimate may help resolve the issue. By the way, I am using SAS 9.4. 

 

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
  • 2 replies
  • 1492 views
  • 0 likes
  • 2 in conversation