A SAS Macro for Univariate Logistic Regression Masud Rana Clinical Research Support Unit, College of Medicine University of Saskatchewan Saskatoon, Saskatchewan, S7N 5E5, Canada Saskatoon SAS User Group (SUCCESS) October 24, 2013 Masud Rana (CRSU) SAS Macro October 24, 2013 1 / 15
15
Embed
A SAS Macro for Univariate Logistic Regression Group Presentation… · A SAS Macro for Univariate Logistic Regression Masud Rana Clinical Research Support Unit, College of Medicine
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
A SAS Macro for Univariate Logistic Regression
Masud Rana
Clinical Research Support Unit, College of MedicineUniversity of Saskatchewan
Saskatoon, Saskatchewan, S7N 5E5, Canada
Saskatoon SAS User Group (SUCCESS)
October 24, 2013
Masud Rana (CRSU) SAS Macro October 24, 2013 1 / 15
Outline
1 Logistic Regression
2 Macro
3 Example
Masud Rana (CRSU) SAS Macro October 24, 2013 2 / 15
Logistic Regression
When & Why
♦ Response variable iscategorical, often binary:Yes/NoAcceptable/Not acceptablePhenomena takes place/doesnot take place
♦ Violates the assumption oflinearity in normal regression.
♦ Error terms are heteroscedasticand not normal.
Masud Rana (CRSU) SAS Macro October 24, 2013 3 / 15
Logistic Regression
Area of Application
♣ Health Sciences: questions about disease: yes or no?
♣ Social Sciences: deals with great deal of dichotomous variables:employed vs unemployed, married vs unmarried, etc.
♣ Used in economics and marketing to study consumer choice.
♣ Banks use it to assess credit rating of customers
♣ Public Opinion Polls
♣ Used in demand forecasting
Masud Rana (CRSU) SAS Macro October 24, 2013 4 / 15
Logistic Regression
PROC LOGISTIC
Masud Rana (CRSU) SAS Macro October 24, 2013 5 / 15
Macro
What is SAS Macro
A macro is a larger piece of a program that can contain complex logicincluding complete DATA and PROC steps, and macro statements such as%IF -%THEN -%ELSE and %DO-%END. Macros often - but not always- contain macro variables.1
Why use Macro
1 With macros you can make one small change in your program andhave SAS echo that change throughout your program.1
2 Macros can allow you to write a piece of code and use it over andover again in the same or different program.1
3 You can make your program data driven, letting SAS decide what todo based on actual data.1
Masud Rana (CRSU) SAS Macro October 24, 2013 6 / 15
Example
Data
Masud Rana (CRSU) SAS Macro October 24, 2013 7 / 15
Example
Data (Contd.)
Masud Rana (CRSU) SAS Macro October 24, 2013 8 / 15
Example
What predicts what?
♣ Costly or Not
♣ Efficient or Not
♣ Big or Small
♣ Front Wheel Drive or Not
♣ Response Variable: 4
♣ Explanatory Variable: 11
♣ Total Model: 44
Masud Rana (CRSU) SAS Macro October 24, 2013 9 / 15
Example
Macro Code
/*This macro runs univariate logistic regression for any number of outcomes and predictors.It summarizes parameter estimates from different models into two data files: one for numeric and one for character variables. Arguments are:DS=Input DatasetOutcome=Output Variable(s)Numvar=One numeric variable name to generate summary data fileCHARVAR=One Character Variable to generate summary data fileOutvar=One output variable name if there are more than one Outcomes*/