BookmarkSubscribeRSS Feed
YezzieBay
Calcite | Level 5

Hi,

 

I would like to get two decimal places in my output (default is three), but I can't seem to make it work. I tried both ods output and format w.d 8.2 without any success, but maybe I didn't do it properly? This is the the SAS code that I'm using:

 

proc phreg data=have nosummary;

model (entry,exit)*failure(0)=exposure / risklimits;

run;

 

I'm fairly new to SAS so I apologise in advance if I'm not using the correct terminology when posting this. 

4 REPLIES 4
ballardw
Super User

@YezzieBay wrote:

Hi,

 

I would like to get two decimal places in my output (default is three), but I can't seem to make it work. I tried both ods output and format w.d 8.2 without any success, but maybe I didn't do it properly? This is the the SAS code that I'm using:

 

proc phreg data=have nosummary;

model (entry,exit)*failure(0)=exposure / risklimits;

run;

 

I'm fairly new to SAS so I apologise in advance if I'm not using the correct terminology when posting this. 


Please show the code you tried for ODS output that did not work. Best would be to paste code and messages from the log into a code box opened with the forum's {i} menu icon.

 

Other approaches would involve modifying table templates which would be more complex and for some procedures would involve modifying many templates.

YezzieBay
Calcite | Level 5

I've now managed to make ods output work by using this code:

ods output ParameterEstimates=new;   
proc phreg data=have nosummary;
model (entry,exit)*failure(0)=exposure / risklimits;
run;

proc print data=new noobs;
format hazardratio 8.2
HRLowerCL 8.2
HRUpperCL 8.2;
run;

However, this creates a new dataset with the estimates. Would it be possible to get two decimal places in the output from the proc phreg directly? Thanks!  

ballardw
Super User

Run this code:

proc template;
  path sashelp.tmplmst;
  list stat.phreg;
run;

You would have to modify EACH of the templates that show the type of Table and some of the Link to do what you want.

 

For example the template code for Estimates looks like:

proc template;                                                                
   link Stat.PHReg.Estimates to Stat.Lmr.Estimates;                           
   define table Stat.Lmr.Estimates;                                           
      notes "Results from ESTIMATE statements";                               
      dynamic Title Title2 FirstSpace FirstQuant LastQuant FirstQuantMu       
         LastQuantMu FirstQuantExp LastQuantExp;                              
      header H1 H2 QuantHeader QuantMuHeader QuantExpHeader;                  
                                                                              
      define H1;                                                              
         text Title;                                                          
         split = ";";                                                         
         space = FirstSpace;                                                  
      end;                                                                    
                                                                              
      define H2;                                                              
         text Title2;                                                         
         space = 1;                                                           
      end;                                                                    
                                                                              
      define QuantHeader;                                                     
         text "Percentiles";                                                  
         expand = "-";                                                        
         end = LastQuant;                                                     
         start = FirstQuant;                                                  
         spill_margin;                                                        
         generic;                                                             
      end;                                                                    
                                                                              
      define QuantMuHeader;                                                   
         text "Percentiles for Mean";                                         
         expand = "-";                                                        
         end = LastQuantMu;                                                   
         start = FirstQuantMu;                                                
         spill_margin;                                                        
         generic;                                                             
      end;                                                                    
                                                                              
      define QuantExpHeader;                                                  
         text ";Percentiles for;Exponentiated";                               
         expand = "-";                                                        
         end = LastQuantExp;                                                  
         start = FirstQuantExp;                                               
         spill_margin;                                                        
         generic;                                                             
      end;                                                                    
      parent = Stat.LMR.tTests;                                               
   end;                                                                       
run;

Which from the statement parent = Stat.LMR.tTests means you need to look in that template to find the names of more variables that Estimates might contain and then add define statements to set all of the formats as desired.

 

Plus you have to take care not to accidentally replace the SAS supplied templates with your custom template and then tell SAS when to use your custom template in stead of the SAS supplied.

 

Good luck. That would be way beyond the scope of what I have time to help with here.

YezzieBay
Calcite | Level 5

I will try this. Thank you for your help!

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