regression

logisticCode

Description

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.

regression.logisticCode <result=results> <status=rc> / casOut={caslib="string", compress=TRUE|FALSE, indexVars={"variable-name-1" <, "variable-name-2", ...>}, label="string", lifetime=64-bit-integer, maxMemSize=64-bit-integer, memoryFormat="DVR"|"INHERIT"|"STANDARD", name="table-name", promote=TRUE|FALSE, replace=TRUE|FALSE, replication=integer, tableRedistUpPolicy="DEFER"|"NOREDIST"|"REBALANCE", threadBlockSize=64-bit-integer, timeStamp="string", where={"string-1" <, "string-2", ...>}}, comment=TRUE|FALSE, display={caseSensitive=TRUE|FALSE, exclude=TRUE|FALSE, excludeAll=TRUE|FALSE, keyIsPath=TRUE|FALSE, names={"string-1" <, "string-2", ...>}, pathType="LABEL"|"NAME", traceNames=TRUE|FALSE}, fmtWdth=integer, indentSize=integer, intoCutPt=double, iProb=TRUE|FALSE, labelId=integer, lineSize=integer, noTrim=TRUE|FALSE, outputTables={groupByVarsRaw=TRUE|FALSE, includeAll=TRUE|FALSE, names={"string-1" <, "string-2", ...>}|{"key-1"={casouttable-1} <, "key-2"={casouttable-2}, ...>}, repeated=TRUE|FALSE, replace=TRUE|FALSE}, pCatAll=TRUE|FALSE, restore={caslib="string", dataSourceOptions={key-1=any-list-or-data-type-1 <, key-2=any-list-or-data-type-2, ...>}, name="table-name", whereTable={casLib="string", dataSourceOptions={adls_noreq-parameters | bigquery-parameters | cas_noreq-parameters | clouddex-parameters | db2-parameters | dnfs-parameters | esp-parameters | fedsvr-parameters | gcs_noreq-parameters | hadoop-parameters | hana-parameters | impala-parameters | informix-parameters | jdbc-parameters | mongodb-parameters | mysql-parameters | odbc-parameters | oracle-parameters | path-parameters | postgres-parameters | redshift-parameters | s3-parameters | sapiq-parameters | sforce-parameters | singlestore_standard-parameters | snowflake-parameters | spark-parameters | spde-parameters | sqlserver-parameters | ss_noreq-parameters | teradata-parameters | vertica-parameters | yellowbrick-parameters}, importOptions={fileType="ANY"|"AUDIO"|"AUTO"|"BASESAS"|"CSV"|"DOCUMENT"|"DTA"|"ESP"|"EXCEL"|"FMT"|"HDAT"|"IMAGE"|"JMP"|"LASR"|"PARQUET"|"SPSS"|"VIDEO"|"XLS", fileType-specific-parameters}, name="table-name", vars={{format="string", formattedLength=integer, label="string", name="variable-name", nfd=integer, nfl=integer}, {...}}, where="where-expression"}}, tabForm=TRUE|FALSE ;
Settings
ParameterDescription
casOutSpecifies the settings for an output table.
commentWhen set to True, adds comments to the DATA step code.
displaySpecifies a list of results tables to send to the client for display.
fmtWdthSpecifies the width to use for formatting derived numbers such as parameter estimates in the DATA step code.
indentSizeSpecifies the number of spaces to indent the DATA step code for each level.
intoCutPtSpecifies the cutoff point for the INTO column.
iProbWhen set to True, generates individual probabilities.
labelIdSpecifies the label ID to use in array names and statement labels in the DATA step code.
lineSizeSpecifies the line size for the generated code.
noTrimWhen set to True, bases the comparison of variables with formatted values on the full format width with padding.
outputTablesLists the names of results tables to save as CAS tables on the server.
pCatAllWhen set to True, generates the probabilities for all levels of the response.
restoreRestores regression models from a binary large object (BLOB), which is the saved state from a previous run of the `logistic` action.
tabFormWhen set to True, generates the code in a way that is appropriate for storing in a table.
Data Preparation View data prep sheet
Data Creation for Logistic Regression Model

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.

Copied!
1/* Load Hmeq data into CAS */
2DATA mycas.hmeq;
3 SET sampsio.hmeq;
4RUN;
5 
6/* Fit a logistic regression model and save the model state */
7PROC CAS;
8 regression.logistic TABLE='hmeq' class={'job', 'reason'} model={depvar='bad', effects={'job', 'reason', 'loan', 'value'}} store={name='myModelStore', replace=true};
9RUN;
10QUIT;

Examples

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.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 regression.logisticCode restore='myModelStore' casOut={name='ScoringCode', replace=true};
3RUN;
4QUIT;
Result :
A CAS table named 'ScoringCode' is created, containing a single column with the SAS DATA step code. The code can be used to score new data based on the fitted logistic model.

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.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 regression.logisticCode
3 restore='myModelStore'
4 casOut={name='DetailedScoringCode', replace=true}
5 comment=true
6 lineSize=100
7 pCatAll=true;
8RUN;
9QUIT;
Result :
A CAS table named 'DetailedScoringCode' is created. The code within it will be formatted to a 100-character line width, contain explanatory comments, and include logic to calculate the probability for each level of the dependent variable 'bad'.

FAQ

What does the logisticCode action do?
What is the purpose of the 'restore' parameter in the logisticCode action?
How can I generate scoring code into a CAS output table?
Is it possible to add comments to the generated SAS DATA step code?
What does the 'pCatAll' parameter control?
How can I specify the cutoff point for classifying events in the scoring code?