regression

logisticOddsRatio

Description

The logisticOddsRatio action creates a table that compares subpopulations by using odds ratios. This is particularly useful in logistic regression analysis to understand how the odds of a certain outcome change with the value of a predictor variable, potentially at specific levels of other covariates.

regression.logisticOddsRatio { alpha=double, at={{level='ALL'|'REF'|'string'|{'string-1', ...}, value=double|{double-1, ...}, var='variable-name'}}, diff='ALL'|'REF', display={...}, outputTables={...}, restore={...}, unit={{...}}, vars={{...}} };
Settings
ParameterDescription
alphaSpecifies the significance level for the confidence limits of the odds ratios. The default value is 0.05, which corresponds to 95% confidence.
atSpecifies the fixed values or levels for covariates that interact with the odds ratio variable. This allows for the computation of odds ratios at specific points or for specific subgroups.
diffSpecifies which pairs of response levels to compare when computing odds ratios. 'REF' compares each level to the reference level, while 'ALL' computes for all pairs of levels.
displaySpecifies which result tables to display. This can be used to limit the output to only the tables of interest.
outputTablesSpecifies which result tables to save as in-memory CAS tables for further processing.
restoreSpecifies an input CAS table that contains a previously fitted logistic regression model, from which the odds ratios will be calculated.
unitSpecifies the units of change for continuous variables for which odds ratios are to be estimated. This defines the magnitude of change in the variable for which the odds ratio is calculated.
varsSpecifies the variables for which odds ratios are computed. This is the main parameter to define the scope of the analysis.
Data Preparation View data prep sheet
Data Creation for Logistic Regression

First, we need a logistic regression model. Let's create a sample dataset 'getheart' and then fit a logistic model to it. This model will predict the 'Status' of a patient based on their 'Age', 'Sex', and 'Cholesterol' levels. The resulting model will be stored in an item store named 'myModelStore' for the logisticOddsRatio action to use.

Copied!
1 
2DATA casuser.getheart;
3SET sashelp.heart;
4 
5RUN;
6PROC CAS;
7ACTION regression.logistic
8DATA='getheart', class={'Status', 'Sex'}, model={depvar='Status', effects={'Age', 'Sex', 'Cholesterol'}}, store={name='myModelStore', replace=true};
9 
10RUN;
11 
12QUIT;
13 

Examples

This example calculates the odds ratio for the 'Age' variable from the previously fitted logistic model stored in 'myModelStore'. It shows the change in odds for the patient's 'Status' for each one-year increase in age.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3ACTION regression.logisticOddsRatio restore='myModelStore', vars={{var='Age'}};
4 
5RUN;
6 
7QUIT;
8 

This example calculates more complex odds ratios. For the 'Age' variable, it calculates the odds ratio for a 10-year increase. For the 'Cholesterol' variable, it calculates odds ratios at specific values (200, 220, 240). Finally, it computes the odds ratio for 'Sex', but specifically for patients who are 50 years old, demonstrating the use of the 'at' parameter to fix a covariate's value.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3ACTION regression.logisticOddsRatio restore='myModelStore', vars={{var='Age', unit=10}, {var='Cholesterol', at={value={200, 220, 240}}}, {var='Sex', at={var='Age', value=50}}};
4 
5RUN;
6 
7QUIT;
8 

FAQ

What is the purpose of the logisticOddsRatio action in SAS Viya?
How can I specify the significance level for confidence limits in the logisticOddsRatio action?
What is the 'at' parameter used for in the logisticOddsRatio action?
How can I control which pairs of response levels are compared for the odds ratio calculation?
What does the 'restore' parameter do in the logisticOddsRatio action?