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!
title 'Predicted Probabilities';
data loan;
input Education $ Income $ Purchase $ wt;
datalines;
high high yes 54
high high no 23
high low yes 41
high low no 12
low high yes 35
low high no 42
low low yes 19
low low no 8
;
1
title 'Predicted Probabilities';
2
3
DATA loan;
4
INPUT Education $ Income $ Purchase $ wt;
5
DATALINES;
6
high high yes 54
7
high high no 23
8
high low yes 41
9
high low no 12
10
low high yes 35
11
low high no 42
12
low low yes 19
13
low 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!
ods output PredictedValues=Predicted (keep=Education Income PredFunction);
proc catmod data=loan order=data;
weight wt;
response marginals;
model Purchase=Education Income / pred design;
run;
1
ods OUTPUT PredictedValues=Predicted (keep=Education Income PredFunction);
2
PROC CATMODDATA=loan order=DATA;
3
weight wt;
4
response marginals;
5
model Purchase=Education Income / pred design;
6
RUN;
3 Code Block
PROC SORT
Explanation : Sorting the predictions table by decreasing order of the predicted function.
Copied!
proc sort data=Predicted;
by descending PredFunction;
run;
1
2
PROC SORT
3
DATA=Predicted;
4
BY descending PredFunction;
5
RUN;
6
4 Code Block
PROC PRINT
Explanation : Display of sorted predicted results.
Copied!
proc print data=Predicted;
run;
1
PROC PRINTDATA=Predicted;
2
RUN;
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.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.