In this example, the GENMOD procedure is used to perform Poisson regression, and part of the resulting procedure output is
written to a SAS data set with the ODS OUTPUT statement. Insurance claims data are classified by two factors: age group (with
two levels) and car type (with three levels). The following statements create the data set Insure
:
title 'Insurance Claims'; data Insure; input n c Car $ Age; ln = log(n); datalines; 500 42 Small 1 1200 37 Medium 1 100 1 Large 1 400 101 Small 2 500 73 Medium 2 300 14 Large 2 ;
The variable n
represents the number of insurance policyholders, and the variable c
represents the number of insurance claims. The variable Car
represents the type of car involved (classified into three groups), and the variable Age
is the age of a policyholder (classified into two groups).
You can use PROC GENMOD to perform a Poisson regression analysis of these data with a log link function. Assume that the number-of-claims
variable, c
, has a Poisson probability distribution and the log of its mean, , is related to the factors Car
and Age
.
The following statements obtain the names of the objects produced by this PROC GENMOD run. The ODS TRACE statement lists the trace record. If you already know the names, such as by looking them up in the procedure documentation, you do not have to run this step. The following step displays the trace information:
ods trace on; proc genmod data=insure; class car age; model c = car age / dist=poisson link=log offset=ln obstats; run; ods trace off;
The trace record from the SAS log is displayed next:
Output Added: ------------- Name: ModelInfo Label: Model Information Template: Stat.Genmod.ModelInfo Path: Genmod.ModelInfo ------------- Output Added: ------------- Name: NObs Label: Number of observations summary Template: Stat.Genmod.NObs Path: Genmod.NObs ------------- Output Added: ------------- Name: ClassLevels Label: Class Level Information Template: Stat.Genmod.Classlevels Path: Genmod.ClassLevels -------------
Output Added: ------------- Name: ParmInfo Label: Parameter Information Template: Stat.Genmod.Parminfo Path: Genmod.ParmInfo ------------- Output Added: ------------- Name: ModelFit Label: Criteria For Assessing Goodness Of Fit Template: stat.genmod.ModelFit Path: Genmod.ModelFit ------------- Output Added: ------------- Name: ConvergenceStatus Label: Convergence Status Template: Stat.Genmod.ConvergenceStatus Path: Genmod.ConvergenceStatus ------------- Output Added: ------------- Name: ParameterEstimates Label: Analysis Of Parameter Estimates Template: stat.genmod.parameterestimates Path: Genmod.ParameterEstimates ------------- Output Added: ------------- Name: ObStats Label: Observation Statistics Template: Stat.Genmod.Obstats Path: Genmod.ObStats -------------
In the following step, no output is displayed because the ODS SELECT NONE statement is included. The ODS OUTPUT statement
writes the ODS table ObStats to a SAS data set named myObStats
. All of the usual data set options, such as the KEEP= or RENAME= option, can be used in the ODS OUTPUT statement. Thus, to
create the myObStats
data set so that it contains only certain columns from the ObStats table, you can use the data set options as follows:
ods select none; proc genmod data=insure; class car age; model c = car age / dist=poisson link=log offset=ln obstats; ods output ObStats=myObStats(keep=car age pred rename=(pred=PredictedValue)); run;
The KEEP= data set option in the ODS OUTPUT statement specifies that only the variables Car
, Age
, and Pred
are written to the data set. The RENAME= data set option changes the name of variable Pred
to PredictedValue
. The following statements sort the output data set myObStats
, select all output, and produce Output 20.4.1:
proc sort data=myObStats; by descending PredictedValue; run; ods select all; proc print data=myObStats noobs; title2 'Values of Car, Age, and the Predicted Values'; run;
The ODS SELECT NONE statement remains in effect until it is explicitly canceled (for example, with the ODS SELECT ALL statement).
Output 20.4.1: The ObStats Table Created as a SAS Data Set