/* hypothetical chocolate choices from SAS Examples book */ data chocs; title 'Chocolate Candy Data'; input subj choose dark soft nuts @@; t=2-choose; * Needed when using PROC PHREG; if dark=1 then drk='dark'; else drk='milk'; * Used to make a nice tables at end; if soft=1 then sft='soft'; else sft='hard'; if nuts=1 then nts='nuts'; else nts='no nuts'; datalines; 1 0 0 0 0 1 0 0 0 1 1 0 0 1 0 1 0 0 1 1 1 1 1 0 0 1 0 1 0 1 1 0 1 1 0 1 0 1 1 1 2 0 0 0 0 2 0 0 0 1 2 0 0 1 0 2 0 0 1 1 2 0 1 0 0 2 1 1 0 1 2 0 1 1 0 2 0 1 1 1 3 0 0 0 0 3 0 0 0 1 3 0 0 1 0 3 0 0 1 1 3 0 1 0 0 3 0 1 0 1 3 1 1 1 0 3 0 1 1 1 4 0 0 0 0 4 0 0 0 1 4 0 0 1 0 4 0 0 1 1 4 1 1 0 0 4 0 1 0 1 4 0 1 1 0 4 0 1 1 1 5 0 0 0 0 5 1 0 0 1 5 0 0 1 0 5 0 0 1 1 5 0 1 0 0 5 0 1 0 1 5 0 1 1 0 5 0 1 1 1 6 0 0 0 0 6 0 0 0 1 6 0 0 1 0 6 0 0 1 1 6 0 1 0 0 6 1 1 0 1 6 0 1 1 0 6 0 1 1 1 7 0 0 0 0 7 1 0 0 1 7 0 0 1 0 7 0 0 1 1 7 0 1 0 0 7 0 1 0 1 7 0 1 1 0 7 0 1 1 1 8 0 0 0 0 8 0 0 0 1 8 0 0 1 0 8 0 0 1 1 8 0 1 0 0 8 1 1 0 1 8 0 1 1 0 8 0 1 1 1 9 0 0 0 0 9 0 0 0 1 9 0 0 1 0 9 0 0 1 1 9 0 1 0 0 9 1 1 0 1 9 0 1 1 0 9 0 1 1 1 10 0 0 0 0 10 0 0 0 1 10 0 0 1 0 10 0 0 1 1 10 0 1 0 0 10 1 1 0 1 10 0 1 1 0 10 0 1 1 1 ; /*********************** PHREG *******************************/ title 'Conditional Logit model fit using PROC PHREG'; proc phreg data=chocs outest=betas; strata subj; model t*choose(0)=dark soft nuts; run; /*********************** GENMOD *****************************/ title 'Conditional logit model: values of variables differ over choices'; proc genmod data=chocs; class subj dark soft nuts; model choose = dark soft nuts /link=log dist=poi obstats; ods output ObStats=obstats; run; title 'Predicted probabilities for different chocolates'; proc sort data=obstats; by subj pred ; proc print; where subj="1"; var dark soft nuts pred ; run; /*********************** MDC ****************************/ title 'Using PROC MDC to fit conditional model'; proc mdc data=chocs; model choose = dark soft nuts / type=clogit nchoice=8 covest=hessian; id subj; run;