BookmarkSubscribeRSS Feed
mdvogan
Calcite | Level 5

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;

3 REPLIES 3
Reeza
Super User

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.

mdvogan
Calcite | Level 5

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.

ballardw
Super User

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1300 views
  • 0 likes
  • 3 in conversation