The SAS Output Delivery System and reporting techniques

Proc Genmod ODS Rounding

Reply
New Contributor
Posts: 4

Proc Genmod ODS Rounding

Hello All,

     Is it possible to control the rounding of proc genmod's, or any other procedure's, output using ODS? The code below gives me a .csv file with statistics rounded only to the fourth decimal place. The only approach I could think of is to apply a format with more room for decimals to an outputted dataset, but I would like to avoid this if possible.

Thanks!

ods csvall file = "file_name";

proc genmod data = data;

     class categorical_vars(ref = reference_level);

     model y = x;

     repeated subject = cluster;

     where some_condition;

run;

ods csvall close;

Super User
Posts: 19,063

Re: Proc Genmod ODS Rounding

Generally not easily. 

Usually you can save your output to datasets, customize and then output to whatever destination.

I'm curious as to what the benefits of outputting the output to a CSV file. It seems like it wouldn't have formatting and would be hard to read.

New Contributor
Posts: 4

Re: Proc Genmod ODS Rounding

Merely convenience.

I have many models in a macro that is run with different dependent variables. The csv output allows all of the output to stay in one file which a preformatted excel file takes as input to make nice tables for a paper.

Thanks for you reply. It looks like I'll have to go in that direction.

Super User
Posts: 11,114

Re: Proc Genmod ODS Rounding

To change ODS output appearance involves PROC Template and modifying table descriptions.

The first step would be to run one analysis with the ODS TRACE ON to determine the tables used.

Then use either proc template to list the table description or find the template browser to look up for example

The description of stat.genmod.GEEFitCriteria

Which will look something like:

table Stat.Genmod.GEEFitCriteria / store = SASHELP.TMPLSTAT;       

      notes "GEE Fit Criteria";                                              

      column Criterion Value;                                                

      header head;                                                           

                                                                             

      define head;                                                           

         text "GEE Fit Criteria";                                            

         space = 1;                                                          

      end;                                                                   

                                                                             

      define Criterion;                                                      

         print_headers = OFF;                                                

      end;                                                                   

                                                                             

      define Value;                                                          

         format = 12.4;                                                      

         print_headers = OFF;                                                

      end;                                                                   

   end;           

find the format assigned to the values you want to modify, likely VALUE in this case

Then use template to modify:

proc template;                                                               

   define table Stat.Genmod.GEEFitCriteria / store = SASHELP.TMPLSTAT;       

      notes "GEE Fit Criteria";                                              

      column Criterion Value;                                                

      header head;                                                           

                                                                             

      define head;                                                           

         text "GEE Fit Criteria";                                            

         space = 1;                                                          

      end;                                                                   

                                                                             

      define Criterion;                                                      

         print_headers = OFF;                                                

      end;                                                                   

                                                                             

      define Value;                                                          

         format = 16.8;/* or whatever format you think appropriate*/                                                      

         print_headers = OFF;                                                

      end;                                                                   

   end;                                                                      

run; 

For some shared values such as a p-value you find the base template such as common.pvalue which looks something like

   define column Common.PValue;                                              

      notes "Default p-value column";                                        

      just = r;                                                              

      format = pvalue6.4;       <= Change this and you'll change p-values system wide                                             

   end; 

There is an example in the on-line help for proc template on modifying a table template for proc univariate.

One nice thing about this approach is you can make it semi-permanent by not clearing the definition. That's also a bad thing if you don't remember where you kept the code and want to change behavior later. Getting back to default is always easy though.

Good luck

Ask a Question
Discussion stats
  • 3 replies
  • 453 views
  • 0 likes
  • 3 in conversation