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;
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.
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.
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.