The logisticCode action writes SAS DATA step code that can be used to compute predicted values for a fitted logistic regression model. This action is essential for operationalizing your model, allowing you to apply the scoring logic to new datasets without needing to run the logistic action again. It takes a saved model from the 'logistic' action as input and generates scoring code.
| Parameter | Description |
|---|---|
| casOut | Specifies the settings for an output table. |
| comment | When set to True, adds comments to the DATA step code. |
| display | Specifies a list of results tables to send to the client for display. |
| fmtWdth | Specifies the width to use for formatting derived numbers such as parameter estimates in the DATA step code. |
| indentSize | Specifies the number of spaces to indent the DATA step code for each level. |
| intoCutPt | Specifies the cutoff point for the INTO column. |
| iProb | When set to True, generates individual probabilities. |
| labelId | Specifies the label ID to use in array names and statement labels in the DATA step code. |
| lineSize | Specifies the line size for the generated code. |
| noTrim | When set to True, bases the comparison of variables with formatted values on the full format width with padding. |
| outputTables | Lists the names of results tables to save as CAS tables on the server. |
| pCatAll | When set to True, generates the probabilities for all levels of the response. |
| restore | Restores regression models from a binary large object (BLOB), which is the saved state from a previous run of the `logistic` action. |
| tabForm | When set to True, generates the code in a way that is appropriate for storing in a table. |
First, we need to create a logistic regression model and save its state. The `logisticCode` action will then use this saved state. We'll use the `Hmeq` dataset, a common dataset for modeling home equity loan defaults.
| 1 | /* Load Hmeq data into CAS */ |
| 2 | DATA mycas.hmeq; |
| 3 | SET sampsio.hmeq; |
| 4 | RUN; |
| 5 | |
| 6 | /* Fit a logistic regression model and save the model state */ |
| 7 | PROC CAS; |
| 8 | regression.logistic TABLE='hmeq' class={'job', 'reason'} model={depvar='bad', effects={'job', 'reason', 'loan', 'value'}} store={name='myModelStore', replace=true}; |
| 9 | RUN; |
| 10 | QUIT; |
This example generates a basic SAS DATA step code from the saved model 'myModelStore'. The generated code is then stored in the 'ScoringCode' CAS table.
| 1 | PROC CAS; |
| 2 | regression.logisticCode restore='myModelStore' casOut={name='ScoringCode', replace=true}; |
| 3 | RUN; |
| 4 | QUIT; |
This example generates a more readable SAS DATA step code by adding comments, specifying a line size, and including probabilities for all response levels. This is useful for understanding and debugging the scoring logic.
| 1 | PROC CAS; |
| 2 | regression.logisticCode |
| 3 | restore='myModelStore' |
| 4 | casOut={name='DetailedScoringCode', replace=true} |
| 5 | comment=true |
| 6 | lineSize=100 |
| 7 | pCatAll=true; |
| 8 | RUN; |
| 9 | QUIT; |