Logistic Regression: A Self-learning Text, Third Edition (Statistics in the Health Sciences)

(vip2019) #1

For this example, we shall use the SAS permanent datasetevans.sas7bdat. A LIB-
NAME statement is needed to indicate the path to the location of the SAS dataset. In
our examples, we assume the file is located on the C drive. The LIBNAME statement
includes a reference name as well as the path. We call the reference name REF. The
code is as follows:


LIBNAME REF‘C:\’;

The user is free to define his/her own reference name. The path to the location of the
file is given between the single quotation marks. The general form of the code is


LIBNAME Your reference name ‘Your path to file location’;

All of the SAS programming will be written in capital letters for readability. How-
ever, SAS isnotcase sensitive. If a program is written with lower case letters, SAS
reads them as upper case. The number of spaces between words (if more than one)
has no effect on the program. Each SAS programming statement ends with a
semicolon.


The code to run a standard logistic regression with PROC LOGISTIC is as follows:


PROC LOGISTIC DATA¼REF.EVANS DESCENDING;
MODEL CHD¼CAT AGE CHL ECG SMK HPT CH CC / COVB;
RUN;

With the LIBNAME statement, SAS recognizes a two-level file name: the refer-
ence name and the file name without an extension. For our example, the SAS file
name is REF.EVANS. Alternatively, a temporary SAS dataset could be created
and used. However, a temporary SAS dataset has to be recreated in every SAS
session as it is deleted from memory when the user exits SAS. The following
code creates a temporary SAS dataset called EVANS from the permanent SAS
dataset REF.EVANS.


DATA EVANS;
SET REF.EVANS;
RUN;

The DESCENDING option in the PROC LOGISTIC statement instructs SAS that the
outcome event of interest is CHD¼1 rather than the default, CHD¼0. In other
words, we are interested in modeling the P(CHD¼1) rather than the P(CHD¼0).
Check the Response Profile in the output to see that CHD¼1 is listed before CHD¼0.
In general, if the output produces results that are the opposite of what you would
expect, chances are that there is an error in coding, such as incorrectly omitting (or
incorrectly adding) the DESCENDING option.


Options requested in the MODEL statement are preceded by a forward slash.
The COVB option requests the variance–covariance matrix for the parameter
estimates.


SAS 603

Free download pdf