ODS output Application Tips Collections
Click to download pdf paper:
NameLen option: NO truncation in the model output
ODS Trace on: To find out the output ODS table name for a PROC
ODs html newfile=proc: starts a new body file for a new procedure
Here is some situation you might face when you are doing modeling:
"When I first used ODS OUTPUT with PROC LOGISTIC, my variable names were all 8 characters long, so
when I went to run PROC LOGISTIC with variable names as long as the SAS allowed 32 characters, I
was surprised to find the names truncated to 20 characters."
To solve this output truncation issue, we need to use the NameLen option.
The variable name is not technically outputted, but rather an "effect name". For
all but one, the length can be anywhere from 20 to 200. For PROC CATMOD, the length can be between
24 and 200. Here is an example:
ods output ParameterEstimates;
proc glm data= datain namelen=32;
RSPIND = var1 var2 var3;
ods output close;
The explanation in SAS Help Documentation of the NAMELEN option varies slightly from PROC to PROC, but is essentially the
same: "NAMELEN=n specifies the length of effect names in tables and output data sets to be n characters long, where n is a value
between 20 and 200 characters. The default length is 20 characters."
The definition in the PROC GLMMOD documentation differs
the most from the others: "NAMELEN=n specifies the maximum length for an effect name. Effect names are listed in the table of
parameter definitions and stored in the EFFNAME variable in the OUTPARM= data set. By default, n=20. You can specify if 20
characters are not enough to distinguish between effects, which may be the case if the model includes a high-order interaction
between variables with relatively long, similar names."
Question 2: When you were running a SAS procedure, and you were wondering where are the output tables? for example, where are the coefficients parameters output for the reg procedure?
The simplest way to find out the output ODS table name for a PROC is to use the ODS TRACE ON
statement, for example:
ods exclude ParameterEstimates ModelANOVA FitStatistics ClassLevels(persist);
proc glm data=out1 namelen=100 ;
class &class_var. ;
model Log_Price = &Independent_Var/ solution;
output out=res predicted=pred residual=resid rstudent=student_r;
ods output ParameterEstimates=Coef_Estimate
ModelANOVA=Anova1 NObs=NObs FitStatistics= RSquare;
ods trace on;
ods output ParameterEstimates=Parameter_Estimates;
proc reg data=sashelp.bweight
outest=est1 outsscp=sscp1 rsquare;
eq1: model weight=boy smoke mom_age visit ed cigsper;
eq2: model weight=boy smoke mom_age visit ed cigsper married black;
run; ods trace off;
We have used the coding: ods exclude ParameterEstimates(persist);
to suppress the particular output into html or sas output.
Sometimes you might feel you have too much output in the sas html/output window, just want to suppress some of them showing up in html or sas output(but you still get the output in the dataset format,
instead of html or sas output). If you use the option noprint
, that might prevent all the datasets format output.
The PERSIST option in the ODS EXCLUDE statement excludes the table for the entire SAS session or until you execute an ODS SELECT statement or an ODS EXCLUDE NONE statement. If you omit the PERSIST option, the exclusion list is cleared when the procedure terminates.
In the Log window output, it showes what tables are generated in the output:
Question 3: When we generate html or pdf output, how do we control the output hierarchy? For example,
How can we generate one page ouput for each level of interest?
Output Added: -------------
Label: Parameter Estimates
ODS automatically names new files by incrementing the name of the body file. For example, if you specify BODY='REPORT.HTML',
ODS names the first body file REPORT.HTML. Additional body files are named REPORT1.HTML, REPORT2.HTML, and so forth.
If you end the file name with a digit, ODS begins incrementing with that digit. For instance, if you specify BODY='MAY5.HTML',
ODS names the first body file MAY5.HTML. Additional body files are named MAY6.HTML, MAY7.HTML, and so forth.
ods html path = "c:\directory\"
body = 'Fifth_Example.html' * or specify directory: "c:\... .html";
style = CBD_STANDARD
headtext = '*** This is sample header text ***';
newfile = bygroup * one page for one group output;
newfile = proc * starts a new body file each time starting a new procedure;
newfile = NONE * writes all output to the body file that is currently open;
newfile = OUTPUT *starts a new body file for each output object;
newfile = Page * starts a new body file for each page of output;
proc report data = MYDATA nowindows;
column branch team customer loan_auth loan_os deposit_vol;
title1 "Example Output";run;
ods html close;
Acknowledgement: some tutorials are coming from the SAS paper by Oltsik.
Continue to next:
Nodup and Nodupkey
SAS tutorial home
Tricky way to process data, extend weekly to daily
Statistics tutorial home