Resources

Conditional Logit

/*--------------------------------------------------------------

                    SAS Sample Library

        Name: mdcex02.sas
 Description: Example program from SAS/ETS User's Guide,
              The MDC Procedure
       Title: Conditional Logit
     Product: SAS/ETS Software
        Keys: multinomial discrete choice
        PROC: MDC
       Notes:

--------------------------------------------------------------*/

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
18.5  84.0 Auto
82.0  38.0 Auto
8.6  1.6  Transit
22.5  74.1 Auto
51.4  83.8 Auto
81.0  19.2 Transit
51.0  85.0 Auto
62.2  90.1 Auto
95.1  22.2 Transit
41.6  91.5 Auto
;

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;

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

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;

proc print data=new3(obs=9);
run;