LOGSELECT Procedure

Example 18.7 Restoring a Stored Model

(View the complete code for this example.)

The Sashelp.JunkMail data set from Example 18.3 is used here to show how to store a model and later how to restore that same model for further processing. The following program fits a model by using a SELECTION statement, then stores the model by using a STORE statement. The NOTE= option in the STORE statement stores a few notes along with the model; you might also want to store the submitted program. The DISPLAY statement suppresses all output.

data mylib.JunkMail;
   set Sashelp.JunkMail;
run;
proc logselect data=mylib.JunkMail;
   model Class(event='1')=Make Address All _3d Our Over Remove Internet Order
         Mail Receive Will People Report Addresses Free Business Email You
         Credit Your Font _000 Money HP HPL George _650 Lab Labs Telnet _857
         Data _415 _85 Technology _1999 Parts PM Direct CS Meeting Original
         Project RE Edu Table Conference Semicolon Paren Bracket Exclamation
         Dollar Pound CapAvg CapLong CapTotal;
   display / excludeall;
   selection method=forward(maxstep=5);
   store mylib.mymodel /
         note="Generated with stepwise selection.";
run;

The following program replays the standard tables from the fitted model. You can also specify the STB, CLB, CORRB, COVB, and TYPE3 options and the CODE and ODDSRATIO statements, because they do not require access to data.

proc logselect restore=mylib.mymodel stb clb corrb covb type3;
   code;
   oddsratio;
run;

Information about the item store is displayed in Output 18.7.1. The Replay section is displayed in Output 18.7.2 through Output 18.7.5.

Output 18.7.1: Store Information

Store Information
NameMYMODEL
Data SourceJUNKMAIL
Data Libname<<your library>>
ProcedureLOGSELECT
Actionregression.logistic
Action Version1.0.6
Date19May2023:14:02:33

Generated with stepwise selection.


The standard tables from PROC LOGSELECT are displayed next, beginning with the "Model Information" table in Output 18.7.2.

Output 18.7.2: Replay Section

The LOGSELECT Procedure
 
Replay

Model Information
Response VariableClass
DistributionBinary
Link FunctionLogit
Optimization TechniqueNewton-Raphson with Ridging

Number of Observations Read4601
Number of Observations Used4601

Response Profile
Ordered
Value
ClassTotal
Frequency
102788
211813

Probability modeled is Class = 1.



Output 18.7.3: Replay Section (continued)

Convergence criterion (ABSGCONV=1E-7) satisfied.

Dimensions
Columns in Design6
Number of Effects6
Max Effect Columns1
Rank of Design6
Parameters in Optimization6

Testing Global Null Hypothesis: BETA=0
TestDFChi-SquarePr > ChiSq
Likelihood Ratio52677.9370<.0001


The fit statistics shown in Output 18.7.4 are those that are computed when the original model is fit. If you specify the PARTFIT option or a PARTITION statement when the original model is fit, then this table always includes the additional statistics. However, specifying a PARTFIT option when you restore the model does not include the additional statistics in this table in the Replay section. Instead, the same table that appears in the Restore section is expanded; see Output 18.7.8.

Output 18.7.4: Replay Section (continued)

Fit Statistics
-2 Log Likelihood3492.21579
AIC (smaller is better)3504.21579
AICC (smaller is better)3504.23408
SBC (smaller is better)3542.81997

Parameter Estimates
ParameterDFEstimateStandard
Error
Chi-SquarePr > ChiSq95% Confidence LimitsStandardized
Estimate
Intercept1-2.0070450.0574441220.7512<.0001-2.11963-1.89446 
Remove14.6747310.371458158.3777<.00013.946695.402781.008867
Free11.0572490.093489127.8902<.00010.874011.240480.481347
Your10.4658180.035907168.2990<.00010.395440.536190.308391
_00014.5826740.46180998.4719<.00013.677545.487800.885020
Dollar18.2085860.631423169.0034<.00016.971029.446151.112771


Output 18.7.5: Replay Section (continued)

Parameter Estimates Covariance Matrix
ParameterInterceptRemoveFreeYour_000Dollar
Intercept0.003300-0.00318-0.00128-0.00094-0.00300-0.00847
Remove-0.003180.1380-0.00136-0.00089-0.00279-0.00730
Free-0.00128-0.001360.008740-0.000240.000223-0.00156
Your-0.00094-0.00089-0.000240.001289-0.00025-0.00225
_000-0.00300-0.002790.000223-0.000250.2133-0.05709
Dollar-0.00847-0.00730-0.00156-0.00225-0.057090.3987

Parameter Estimates Correlation Matrix
ParameterInterceptRemoveFreeYour_000Dollar
Intercept1.0000-0.1488-0.2393-0.4550-0.1131-0.2335
Remove-0.14881.0000-0.0393-0.0667-0.0163-0.0311
Free-0.2393-0.03931.0000-0.07060.0052-0.0264
Your-0.4550-0.0667-0.07061.0000-0.0149-0.0994
_000-0.1131-0.01630.0052-0.01491.0000-0.1958
Dollar-0.2335-0.0311-0.0264-0.0994-0.19581.0000


Output 18.7.6: Replay Section (continued)

Model Analysis of Variance (Type
III)
EffectDFChi-SquarePr > ChiSq
Remove1158.3777<.0001
Free1127.8902<.0001
Your1168.2990<.0001
_000198.4719<.0001
Dollar1169.0034<.0001

Odds Ratios
DescriptionEstimate95% Wald
Confidence Limits
p-ValuePercent
Change
_00097.77639.549241.726<.00019677.55
Dollar>999.999>999.999>999.999<.0001367134.6
Free2.8782.3973.457<.0001187.84
Remove107.20451.764222.022<.000110620.38
Your1.5931.4851.709<.000159.33


Output 18.7.7: Replay Timing

Task Timing
TaskSecondsPercent
Model Restoration0.000.30%
Setup and Parsing0.1037.06%
Producing Score Code0.001.27%
Type III Sums of Squares0.000.99%
Display0.001.70%
Cleanup0.000.00%
Total0.27100.00%


If you specify the CTABLE, LACKFIT, ASSOCIATION, or PARTFIT option or the OUTPUT statement, then you must also specify an input data table. The following program requests these tables; the Replay section tables are produced but not displayed here.

proc logselect restore=mylib.mymodel data=mylib.JunkMail
   association ctable(cutpt=0.1 to 0.9 by 0.1) lackfit partfit;
   output out=mylib.out p cbar;
proc print data=mylib.out(obs=1);
run;

The first table that is displayed in the Restore section (Output 18.7.8) is the "Postfit Information" table, which contains the name of the input data table and information usually displayed in an "NObs" table. The next two tables are the "Response Profile" and "Fit Statistics" tables, which are computed from the JunkMail data.

Output 18.7.8: Restore Section

Results for JUNKMAIL

Postfit Information
Postfit Data SourceJUNKMAIL
Number of Observations Read4601
Number of Observations Used4601

Response Profile
Ordered
Value
ClassTotal
Frequency
102788
211813

Probability modeled is Class = 1.


Fit Statistics
-2 Log Likelihood3492.21579
AIC (smaller is better)3504.21579
AICC (smaller is better)3504.23408
SBC (smaller is better)3542.81997
Average Square Error0.10819
-2 Log L (Intercept-only)6170.15284
R-Square0.44124
Max-rescaled R-Square0.59754
McFadden's R-Square0.43401
Misclassification Rate0.14606
Difference of Means0.52695


The "Association" and "Classification" tables in Output 18.7.9 also provide information that is computed from the input data table.

Output 18.7.9: Restore Section (continued)

Association of Predicted Probabilities
and Observed Responses
Concordance Index (AUC)0.9125
Somers' D0.8250
Gamma0.8589
Tau-a0.3940
Pairs5054644
Percent Concordant89.2764
Percent Discordant6.7789
Percent Tied3.9447

Classification Table
Probability
Level
CorrectIncorrect
EventNoneventEventNonevent
0.10001813027880
0.200016132230558200
0.300014832491297330
0.400013632598190450
0.500012892640148524
0.600012132675113600
0.70001132269692681
0.80001029272266784
0.9000858275038955


The two Hosmer-Lemeshow tables whose content is computed from the input data are shown in Output 18.7.10.

Output 18.7.10: Restore Section (continued)

Partition for the Hosmer and Lemeshow Test
GroupTotalObserved 1Expected 1Observed 0Expected 0
11763121208.8516421554.15
24614568.63416392.37
346011095.92350364.08
4460235158.10225301.90
5461355315.79106145.21
6460429431.123128.88
7536518534.59181.41

Hosmer and Lemeshow Goodness-of-Fit
Test
Chi-SquareDFPr > ChiSq
322.29975<.0001


The first line of the output data table is displayed in Output 18.7.11. Note that the CBAR statistic is not produced because the computation requires the original input data table.

Output 18.7.11: First Observation from Output Data Table

Obs_PRED_
10.22767


You can specify the FITDATA option to indicate that the DATA= table is the original input table so that computation of the CBAR statistic is valid. The first observation in the output data table is shown in Output 18.7.12 and displays the CBAR statistic.

proc logselect restore=mylib.mymodel data=mylib.JunkMail fitdata;
   output out=mylib.out p cbar;
proc print data=mylib.out(obs=1);
run;

Output 18.7.12: First Observation from Output Data Table with FITDATA Option

Obs_PRED__CBAR_
10.22767.001559475


Last updated: June 22, 2026