MDC Procedure

Example 23.2 Conditional Logit and Data Conversion

(View the complete code for this example.)

In this example, data are prepared for use by the MDCDATA statement. Sometimes, choice-specific information is stored in multiple variables. Since the MDC procedure requires multiple observations for each decision maker, you need to arrange the data so that there is an observation for each subject-alternative (individual-choice) combination. Simple binary choice data are obtained from Ben-Akiva and Lerman (1985). The following statements create the SAS data set:

data travel;
   length mode $ 8;
   input auto transit mode $;
datalines;
52.9   4.4 Transit
4.1   28.5 Transit
4.1   86.9 Auto
56.2  31.6 Transit
51.8  20.2 Transit
0.2   91.2 Auto
27.6  79.7 Auto
89.9  2.2  Transit
41.5  24.5 Transit
95.0  43.5 Transit
99.1  8.4  Transit

   ... more lines ...   

The travel time is stored in two variables, auto and transit. In addition, the chosen alternatives are stored in a character variable, mode. The choice variable, mode, is converted to a numeric variable, decision, since the MDC procedure supports only numeric variables. The following statements convert the original data set, travel, and estimate the binary logit model. The first 10 observations of a relevant subset of the new data set and the parameter estimates are displayed in Output 23.2.1 and Output 23.2.2, respectively.

data new;
   set travel;
   retain id 0;
   id+1;
   /*-- create auto variable --*/
   decision = (upcase(mode) = 'AUTO');
   ttime = auto;
   autodum = 1;
   trandum = 0;
   output;
   /*-- create transit variable --*/
   decision = (upcase(mode) = 'TRANSIT');
   ttime = transit;
   autodum = 0;
   trandum = 1;
   output;
run;
proc print data=new(obs=10);
   var decision autodum trandum ttime;
   id id;
run;

Output 23.2.1: Converted Data

iddecisionautodumtrandumttime
101052.9
11014.4
20104.1
210128.5
31104.1
300186.9
401056.2
410131.6
501051.8
510120.2


The following statements perform the binary logit estimation:

proc mdc data=new;
   model decision = autodum ttime /
            type=clogit
            nchoice=2;
   id id;
run;

Output 23.2.2: Binary Logit Estimation of Modal Choice Data

The MDC Procedure
 
Conditional Logit Estimates

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
autodum1-0.23760.7505-0.320.7516
ttime1-0.05310.0206-2.570.0101


In order to handle more general cases, you can use the MDCDATA statement. Choice-specific dummy variables are generated and multiple observations for each individual are created. The following example converts the original data set travel by using the MDCDATA statement and performs conditional logit analysis. Interleaved data are output into the new data set new3. This data set has twice as many observations as the original travel data set.

proc mdc data=travel;
   mdcdata varlist( x1 = (auto transit) )
           select=mode
           id=id
           alt=alternative
           decvar=Decision / out=new3;
   model decision = auto x1 /
            nchoice=2
            type=clogit;
   id id;
run;

The first nine observations of the modified data set are shown in Output 23.2.3. The result of the preceding program is listed in Output 23.2.4.

Output 23.2.3: Transformed Model Choice Data

ObsMODEAUTOTRANSITX1IDALTERNATIVEDECISION
1TRANSIT1052.9110
2TRANSIT014.4121
3TRANSIT104.1210
4TRANSIT0128.5221
5AUTO104.1311
6AUTO0186.9320
7TRANSIT1056.2410
8TRANSIT0131.6421
9TRANSIT1051.8510


Output 23.2.4: Results Using MDCDATA Statement

The MDC Procedure
 
Conditional Logit Estimates

Parameter Estimates
ParameterDFEstimateStandard
Error
t ValueApprox
Pr > |t|
AUTO1-0.23760.7505-0.320.7516
X11-0.05310.0206-2.570.0101


Last updated: June 19, 2025