Published on :
Statistics CREATION_INTERNE

Categorical Data Analysis with PROC CATMOD - Example 11

This code is also available in: Deutsch Español Français
Awaiting validation
This script generates fictitious loan data (education, income, purchase). It uses the CATMOD procedure to model the response variable 'Purchase' based on 'Education' and 'Income'. Predicted probabilities are captured in an output table via ODS, sorted by decreasing probability, and then displayed.
Data Analysis

Type : CREATION_INTERNE


Data is manually defined in the DATA step 'loan' using the 'datalines' statement.

1 Code Block
DATA STEP Data
Explanation :
Creation of the 'loan' dataset containing the variables Education, Income, Purchase, and the weight wt.
Copied!
1title 'Predicted Probabilities';
2 
3DATA loan;
4 INPUT Education $ Income $ Purchase $ wt;
5 DATALINES;
6high high yes 54
7high high no 23
8high low yes 41
9high low no 12
10low high yes 35
11low high no 42
12low low yes 19
13low low no 8
14;
2 Code Block
PROC CATMOD
Explanation :
Execution of statistical modeling with PROC CATMOD. The 'ods output' statement captures predicted values in the 'Predicted' table.
Copied!
1ods OUTPUT PredictedValues=Predicted (keep=Education Income PredFunction);
2PROC CATMOD DATA=loan order=DATA;
3 weight wt;
4 response marginals;
5 model Purchase=Education Income / pred design;
6RUN;
3 Code Block
PROC SORT
Explanation :
Sorting the predictions table by decreasing order of the predicted function.
Copied!
1 
2PROC SORT
3DATA=Predicted;
4BY descending PredFunction;
5RUN;
6 
4 Code Block
PROC PRINT
Explanation :
Display of sorted predicted results.
Copied!
1PROC PRINT DATA=Predicted;
2RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.