Resources

Discrete Choice 6

 /****************************************************************/
 /*          S A S   S A M P L E   L I B R A R Y                 */
 /*                                                              */
 /*    NAME: MR2010F                                             */
 /*   TITLE: Discrete Choice 6                                   */
 /* PRODUCT: STAT                                                */
 /*  SYSTEM: ALL                                                 */
 /*    KEYS: marketing research                                  */
 /*   PROCS: PHREG, TRANSREG, OPTEX, FACTEX, PLAN, IML           */
 /*    DATA:                                                     */
 /*                                                              */
 /* SUPPORT: saswfk                      UPDATE:  01Oct2010      */
 /*     REF: MR-2010F Discrete Choice                            */
 /*    MISC: This file contains SAS code for the "Discrete       */
 /*          Choice" report, the 01Oct2010 edition, for SAS 9.2. */
 /*                                                              */
 /*          You must install the following macros from          */
 /* http://support.sas.com/techsup/tnote/tnote_stat.html#market  */
 /*                                                              */
 /*          ChoicEff Efficient Choice Designs                   */
 /*          MktAllo  Process a Choice Allocation Study Data Set */
 /*          MktBal   Balanced Experimental Design               */
 /*          MktBIBD  Balanced Incomplete Block Design           */
 /*          MktBlock Block an Experimental Design               */
 /*          MktBSize Balanced Incomplete Block Design Sizes     */
 /*          MktDes   Efficient Experimental Designs             */
 /*          MktDups  Eliminate Duplicate Runs or Choice Sets    */
 /*          MktEval  Evaluate an Experimental Design            */
 /*          MktEx    Efficient Experimental Designs             */
 /*          MktKey   Aid Making the MktRoll KEY= Data Set       */
 /*          MktLab   Change Names, Levels in a Design           */
 /*          MktMDiff MaxDiff (Best-Worst) Choice Modeling       */
 /*          MktMerge Merge a Choice Design with Choice Data     */
 /*          MktOrth  List Orthogonal Designs MktEx Can Make     */
 /*          MktPPro  Optimal Partial Profile Designs            */
 /*          MktRoll  Roll Out a Design Into a Choice Design     */
 /*          MktRuns  Experimental Design Sizes                  */
 /*          PhChoice Customize PROC PHREG for Choice Models     */
 /*                                                              */
 /****************************************************************/

************* Begin PHREG Output Customization **************;
options ls=80 ps=60 nonumber nodate;

%phchoice(on)

************** Begin Food Product Example Code **************;

title 'Consumer Food Product Example';

%macro resmac;
  navail = (x1 < 4) + (x2 < 4) + (x5 < 3) + (x6 < 3) + (x8 < 3);
  if (navail < 2) | (navail > 4) then bad = abs(navail - 3);
  else                                bad = 0;
  %mend;

%mktex(4 4 2 2 3 3 2 3,             /* all attrs of all alternatives        */
       n=26,                        /* number of choice sets                */
       interact=x2*x3 x2*x4 x3*x4 x6*x7, /* interactions                    */
       restrictions=resmac,         /* name of restrictions macro           */
       seed=377,                    /* random number seed                   */
       outr=sasuser.EntreeLinDes1)  /* randomized design stored permanently */

%macro resmac;
   client    = {1.29 1.69 2.09 .}[x1];
   extension = {1.39 1.89 2.39 .}[x2];
   regional  = {1.99 2.49      .}[x5];
   private   = {1.49 2.29      .}[x6];
   national  = {1.99 2.39      .}[x8];

   navail    = (client  ^= .) + (extension ^= .) + (regional ^= .) +
               (private ^= .) + (national  ^= .);
   if (navail < 2) | (navail > 4) then bad = abs(navail - 3);
   else                                bad = 0;
   %mend;

%macro resmac;
   client    = {1.29 1.69 2.09 .}[x1];
   extension = {1.39 1.89 2.39 .}[x2];
   regional  = {"$1.99" "$2.49" "NA"}[x5];
   private   = {"$1.49" "$2.29" "NA"}[x6];
   national  = {"$1.99" "$2.39" "NA"}[x8];

   navail    = (client ^= .) + (extension ^= .) + (regional ^= "NA") +
               (private ^= "NA") + (national  ^= "NA");
   if (navail < 2) | (navail > 4) then bad = abs(navail - 3);
   else                                bad = 0;
   %mend;

%macro resmac;
   client    = {1.29 1.69 2.09 .}[x[1]];
   extension = {1.39 1.89 2.39 .}[x[2]];
   regional  = {"$1.99" "$2.49" "NA"}[x[5]];
   private   = {"$1.49" "$2.29" "NA"}[x[6]];
   national  = {"$1.99" "$2.39" "NA"}[x[8]];

   navail    = (client ^= .) + (extension ^= .) + (regional ^= "NA") +
               (private ^= "NA") + (national  ^= "NA");
   if (navail < 2) | (navail > 4) then bad = abs(navail - 3);
   else                                bad = 0;
   %mend;

%mktex(4 4 2 2 3 3 2 3,             /* all attrs of all alternatives        */
       n=26,                        /* number of choice sets                */
       interact=x2*x3 x2*x4 x3*x4 x6*x7, /* interactions                    */
       optiter=0,                   /* no PROC OPTEX iterations             */
       tabiter=0,                   /* no OA initialization iterations      */
       maxdesigns=10,               /* make at most 10 designs              */
       options=nox,                 /* suppress x1, x2, ... creation        */
       restrictions=resmac,         /* name of restrictions macro           */
       seed=377)                    /* random number seed                   */

* Override maxtime=, make macro run faster so code can be tested;
%let mktexopts=maxtime=0;

title 'Consumer Food Product Example';

%macro resmac;
  navail = (x1 < 4) + (x2 < 4) + (x5 < 3) + (x6 < 3) + (x8 < 3);
  if (navail < 2) | (navail > 4) then bad = abs(navail - 3);
  else                                bad = 0;
  %mend;

%mktex(4 4 2 2 3 3 2 3,             /* all attrs of all alternatives        */
       n=26,                        /* number of choice sets                */
       interact=x2*x3 x2*x4 x3*x4 x6*x7, /* interactions                    */
       restrictions=resmac,         /* name of restrictions macro           */
       seed=151,                    /* random number seed                   */
       maxtime=300 300 60,          /* max time for each major search phase */
       maxiter=10000)               /* max iterations for each phase        */

* Restore normal options;
%let mktexopts=;

%mkteval(data=sasuser.EntreeLinDes1)

%mktruns(4 4 2 2 3 3 2 3)

%mktruns(4 4 2 2 3 3 2 3, interact=x2*x3 x2*x4 x3*x4 x6*x7)

title 'Consumer Food Product Example';

%macro resmac;
  navail = (x1 < 4) + (x2 < 4) + (x5 < 3) + (x6 < 3) + (x8 < 3);
  if (navail < 2) | (navail > 4) then bad = abs(navail - 3);
  else                                bad = 0;
  %mend;

data mat;
   input a b c;
   datalines;
1 1 .
2 3 4
5 5 .
6 7 .
8 8 .
;

%mktex(4 4 2 2 3 3 2 3,             /* all attrs of all alternatives        */
       n=36,                        /* number of choice sets                */
       order=matrix=mat,            /* pairs/trips of cols to work on       */
       interact=x2*x3 x2*x4 x3*x4 x6*x7, /* interactions                    */
       restrictions=resmac,         /* name of restrictions macro           */
       seed=377,                    /* random number seed                   */
       outr=sasuser.EntreeLinDes2)  /* randomized design stored permanently */

%mkteval(data=sasuser.EntreeLinDes2)

data mat;
   input a b c;
   datalines;
1 1 .
2 3 4
5 5 .
6 7 .
8 8 .
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
;

%mktex(4 4 2 2 3 3 2 3,             /* all attrs of all alternatives        */
       n=36,                        /* number of choice sets                */
       order=matrix=mat,            /* pairs/trips of cols to work on       */
       interact=x2*x3 x2*x4 x3*x4 x6*x7, /* interactions                    */
       restrictions=resmac,         /* name of restrictions macro           */
       seed=368,                    /* random number seed                   */
       outr=sasuser.EntreeLinDes3,  /* randomized design stored permanently */
       balance=2,                   /* require near but not perfect balance */
       mintry=5 * n)                /* ignore balance= for first 5 passes   */

* Due to machine differences, you might not get the same design if you run
* the step above, so here is the design that is used in the book;
data sasuser.EntreeLinDes3; input x1-x8 @@; datalines;
4 2 2 1 1 1 2 2 1 3 1 1 1 3 1 1 1 3 2 2 3 2 2 1 1 2 1 2 3 1 2 1 4 1 1 1
2 3 2 1 3 4 1 2 2 3 1 3 3 1 2 2 1 3 2 1 2 4 1 1 3 1 2 3 2 4 2 2 3 1 1 3
2 2 2 2 1 2 1 3 4 3 1 2 2 2 1 1 1 2 2 1 3 3 2 3 2 1 2 1 3 3 1 2 4 3 1 1
3 2 2 3 2 3 1 2 1 1 1 3 3 2 1 1 3 2 1 2 1 4 1 2 1 2 1 2 1 1 1 2 1 3 1 3
3 2 2 1 3 1 1 1 4 3 2 1 1 1 1 2 1 1 2 1 2 2 2 3 4 2 1 2 1 3 2 3 3 1 1 1
1 1 2 3 4 4 2 1 3 2 1 1 3 3 2 1 2 2 1 3 4 3 2 2 3 3 1 2 1 4 1 1 2 1 1 2
2 2 1 1 2 3 1 1 4 4 1 2 1 2 2 1 1 4 2 2 2 1 2 2 3 4 2 1 1 2 2 2 2 1 1 2
3 2 2 2 2 3 2 1 2 3 2 1 4 1 2 2 2 1 2 3 3 3 1 2 3 3 2 2 3 2 2 2 2 3 1 2
;

%mkteval(data=sasuser.EntreeLinDes3)

%mktex(4 4 2 2 3 3 2 3,             /* all attrs of all alternatives        */
       n=36,                        /* number of choice sets                */
       interact=x2*x3 x2*x4 x3*x4 x6*x7, /* interactions                    */
       restrictions=resmac,         /* name of restrictions macro           */
       seed=472,                    /* random number seed                   */
       outr=sasuser.EntreeLinDes4,  /* randomized design stored permanently */
       balance=1,                   /* require near perfect balance         */
       mintry=5 * n)                /* ignore balance= for first 5 passes   */

%mkteval(data=sasuser.EntreeLinDes4)

%macro evaleff(where);
data desv / view=desv; set sasuser.EntreeLinDes3(where=(&where)); run;

proc optex data=desv;
   class x3 x4 x7 / param=orthref;
   model x1-x8 x2*x3 x2*x4 x3*x4 x6*x7;
   generate method=sequential initdesign=desv;
   run; quit;

%mkteval(data=desv)
%mend;

%evaleff(x1 ne 4)
%evaleff(x2 ne 4)
%evaleff(x5 ne 3)
%evaleff(x6 ne 3)
%evaleff(x8 ne 3)

data temp;
   set sasuser.EntreeLinDes3;
   y = 1;
   run;

proc glm data=temp;
   model y = x1-x8 x2*x3 x2*x4 x3*x4 x6*x7 / e aliasing;
   run; quit;

proc glm data=temp;
   model y = x1-x8 x2*x3 x2*x4 x3*x4 x6*x7
             x1|x2|x3|x4|x5|x6|x7|x8@3 / e aliasing;
   run; quit;

%mktblock(data=sasuser.EntreeLinDes3, out=sasuser.EntreeLinDes,
          nblocks=2, seed=448)

* Due to machine differences, you might not get the same design if you run
* the step above, so here is the design that is used in the book;
data sasuser.EntreeLinDes; input Block Run x1-x8 @@; datalines;
1 1 1 3 1 1 1 3 1 1 1 2 3 1 2 2 1 3 2 1 1 3 2 4 2 2 3 1 1 3 1 4 4 3 1 2
2 2 1 1 1 5 1 2 2 1 3 3 2 3 1 6 4 3 1 1 3 2 2 3 1 7 2 3 1 2 1 1 1 3 1 8
1 1 2 1 2 2 2 3 1 9 4 2 1 2 1 3 2 3 1 10 3 1 1 1 1 1 2 3 1 11 4 4 2 1 3
2 1 1 1 12 4 3 2 2 3 3 1 2 1 13 1 4 1 1 2 1 1 2 1 14 2 2 1 1 2 3 1 1 1
15 1 4 2 2 2 1 2 2 1 16 3 4 2 1 1 2 2 2 1 17 2 1 1 2 3 2 2 2 1 18 3 2 2
2 2 3 1 2 2 1 4 2 2 1 1 1 2 2 2 2 1 3 2 2 3 2 2 1 2 3 1 2 1 2 3 1 2 1 2
4 4 1 1 1 2 3 2 1 2 5 3 4 1 2 2 3 1 3 2 6 2 4 1 1 3 1 2 3 2 7 2 2 2 2 1
2 1 3 2 8 2 1 2 1 3 3 1 2 2 9 3 2 1 1 3 2 1 2 2 10 1 4 1 2 1 2 1 2 2 11
1 1 1 2 1 3 1 3 2 12 3 2 2 1 3 1 1 1 2 13 4 3 2 1 1 1 1 2 2 14 3 3 2 1 2
2 1 3 2 15 4 4 1 2 1 2 2 1 2 16 2 3 2 1 2 3 2 1 2 17 4 1 2 2 2 1 2 3 2
18 3 3 1 2 3 3 2 2
;

proc format;
   value yn    1 = 'No'    2 = 'Talker';
   value micro 1 = 'Micro' 2 = 'Stove';
   run;

data key;
   missing N;
   input x1-x8;
   format x1 x2 x5 x6 x8 dollar5.2
          x4 yn. x3 x7 micro.;

   label x1 = 'Client Brand'
         x2 = 'Client Line Extension'
         x3 = 'Client Micro/Stove'
         x4 = 'Shelf Talker'

         x5 = 'Regional Brand'
         x6 = 'Private Label'
         x7 = 'Private Micro/Stove'
         x8 = 'National Competitor';

   datalines;
1.29 1.39 1 1 1.99 1.49 1 1.99
1.69 1.89 2 2 2.49 2.29 2 2.39
2.09 2.39 . . N    N    .    N
N    N    . . .    .    .    .
;

%mktlab(data=sasuser.EntreeLinDes, key=key)

proc sort out=sasuser.EntreeLinDesLab(drop=run); by block x4; run;

proc print label; id block x4; by block x4; run;

proc print data=sasuser.EntreeLinDesLab; format _numeric_; run;

data key;
   input Brand $ 1-10 (Price Micro Shelf) ($);
   datalines;
Client     x1 .  .
Extension  x2 x3 x4
Regional   x5 .  .
Private    x6 x7 .
National   x8 .  .
None       .  .  .
;

%mktroll(design=sasuser.EntreeLinDesLab, key=key, alt=brand, out=rolled,
         keep=x1 x2 x5 x6 x8)

proc print data=sasuser.EntreeLinDesLab(obs=2); run;

proc print data=rolled(obs=12);
   format price dollar5.2 shelf yn. micro micro.;
   id set; by set;
   run;

data sasuser.EntreeChDes(drop=i);
   set rolled;
   array x[6] price x1 -- x8;
   array a[5] a1 a2 a5 a6 a8;
   if nmiss(micro) then micro = 2; /* stove if not a factor in alt      */
   if nmiss(shelf) then shelf = 1; /* not talker if not a factor in alt */

   a1 = -3 * nmiss(x1) + n(x1);    /* alt1: -3 - not avail, 1 - avail */
   a2 = -3 * nmiss(x2) + n(x2);    /* alt2: -3 - not avail, 1 - avail */
   a5 = -2 * nmiss(x5) + n(x5);    /* alt3: -2 - not avail, 1 - avail */
   a6 = -2 * nmiss(x6) + n(x6);    /* alt4: -2 - not avail, 1 - avail */
   a8 = -2 * nmiss(x8) + n(x8);    /* alt5: -2 - not avail, 1 - avail */
   i  = mod(_n_ - 1, 6) + 1;       /* alternative number              */
   if i le 5 then a[i] = 0;        /* 0 effect of an alt on itself    */

   do i = 1 to 6; if nmiss(x[i]) then x[i] = 0; end; /* missing price -> 0    */
   w = brand eq 'None' or price ne 0;                /* 1 - avail, 0 not avail*/
   format price dollar5.2 shelf yn. micro micro.;
   label x1 = 'CE, Client'         a1 = 'AE, Client'
         x2 = 'CE, Extension'      a2 = 'AE, Extension'
         x5 = 'CE, Regional'       a5 = 'AE, Regional'
         x6 = 'CE, Private'        a6 = 'AE, Private'
         x8 = 'CE, National'       a8 = 'AE, National';
   run;

proc print data=sasuser.EntreeChDes(obs=18); by set; id set; run;

%choiceff(data=sasuser.EntreeChDes, /* candidate set of choice sets         */
          init=sasuser.EntreeChDes(keep=set), /* select these sets          */
          intiter=0,                /* evaluate without internal iterations */
                                    /* cross-effects model                  */
                                    /* zero='None' - 'None' level is ref lev*/
          model=class(brand / zero='None')
                                    /* use blank sep to build interact terms*/
                class(brand / zero='None' separators='' ' ') *
                   identity(price)
                                    /* lpr=5 0 uses 5 var name chars in     */
                                    /* label for shelf and 0 for micro      */
                                    /* 'No' is ref level for shelf          */
                                    /* 'Stove' is ref level for micro       */
                class(shelf micro / lprefix=5 0 zero='No' 'Stove')
                                    /* ' on ' is used to build interact term*/
                identity(x1 x2 x5 x6 x8) *
                   class(brand / zero='None' separators=' ' ' on ')
                identity(a1 a2 a5 a6 a8) *
                   class(brand / zero='None' separators=' ' ' on ') /
                lprefix=0           /* lpr=0 labels are created from just   */
                                    /*    levels unless overridden above    */
                order=data,         /* order=data - do not sort levels      */

          nsets=36,                 /* number of choice sets                */
          nalts=6,                  /* number of alternatives               */
          weight=w,                 /* weight to handle unavailable alts    */
          beta=zero)                /* assumed beta vector, Ho: b=0         */

proc print data=tmp_cand(obs=24) label;
   var Brand Price Shelf Micro;
   where w;
   run;

proc print data=tmp_cand(obs=5) label;
   id Brand;
   var BrandClient -- BrandNational;
   where w;
   run;

proc format; value zer 0 = '  0'; run;

proc print data=tmp_cand(obs=5) label;
   id Brand Price;
   var BrandClientPrice -- BrandNationalPrice;
   format BrandClientPrice -- BrandNationalPrice zer5.2;
   where w;
   run;

proc print data=tmp_cand(obs=5) label;
   id Brand Price Shelf Micro;
   var shelftalker micromicro;
   where w;
   run;

proc print data=tmp_cand(obs=4) label;
   id Brand Price;
   var x1Brand:; format x1Brand: zer5.2;
   where w;
   run;

proc print data=tmp_cand(obs=4) label;
   id Brand Price;
   var x2Brand:; format x2Brand: zer5.2;
   where w;
   run;

proc print data=tmp_cand(obs=4) label;
   id Brand Price;
   var x5Brand:; format x5Brand: zer5.2;
   where w;
   run;

proc print data=tmp_cand(obs=4) label;
   id Brand Price;
   var x6Brand:; format x6Brand: zer5.2;
   where w;
   run;

proc print data=tmp_cand(obs=4) label;
   id Brand Price;
   var x8Brand:; format x8Brand: zer5.2;
   where w;
   run;

proc print data=tmp_cand(obs=4) label;
   id Brand Price;
   var a1Brand:;
   where w;
   run;

proc print data=tmp_cand(obs=4) label;
   id Brand Price;
   var a2Brand:;
   where w;
   run;

proc print data=tmp_cand(obs=4) label;
   id Brand Price;
   var a5Brand:;
   where w;
   run;

proc print data=tmp_cand(obs=4) label;
   id Brand Price;
   var a6Brand:;
   where w;
   run;

proc print data=tmp_cand(obs=4) label;
   id Brand Price;
   var a8Brand:;
   where w;
   run;

%mktdups(branded, data=sasuser.EntreeChDes,
         nalts=6, factors=brand price shelf micro)

%let m   = 6;
%let mm1 = %eval(&m - 1);
%let n   = 36;

proc format;
   value yn    1 = 'No'    2 = 'Talker';
   value micro 1 = 'Micro' 2 = 'Stove';
   run;

data _null_;
   array brands[&m] _temporary_ (5 7 1 2 3 -2);
   array u[&m];
   array x[&mm1] x1 x2 x5 x6 x8;
   do rep = 1 to 300;
      if mod(rep, 2) then put;
      put rep 3. +2 @@;
      do j = 1 to &n;
         set sasuser.EntreeLinDesLab point=j;
         do brand = 1 to &m; u[brand] = brands[brand] + 2 * normal(17); end;
         do brand = 1 to &mm1;
            if n(x[brand]) then u[brand] + -x[brand]; else u[brand] = .;
            end;
         if n(u2) and x4 = 2 then u2 + 1; /* shelf talker */
         if n(u2) and x3 = 1 then u2 + 1; /* microwave    */
         if n(u4) and x7 = 1 then u4 + 1; /* microwave    */
         * Choose the most preferred alternative.;
         m = max(of u1-u&m);
         do brand = 1 to &m;
            if n(u[brand]) then if abs(u[brand] - m) < 1e-4 then c = brand;
            end;
         put +(-1) c @@;
         end;
      end;
   stop;
   run;

data results;
   input Subj (choose1-choose&n) (1.);
   datalines;
  1 222224155212222522221221222221212522
  2 222225421242222122221212222221211322
  3 212224521545222122221222221121112522
  4 212125121212222122221222421221212522
  5 222225125212222122521212222221212422
  6 222125523112222122224221212111242522
  7 222225121242222422221122221221112422
  8 222225124212222122221222522221212422
  9 122125121242222122221222222221242322
 10 212125125212222122221211222221112522
 11 222225121212222522221222222123212522
 12 122124121212222422221222221221212522
 13 122225125212222121221222222221212522
 14 222214123142222122221222241221211322
 15 222125121212222122221221221221212421
 16 212124425212222422224112422123212522
 17 212126525212222122524121421226212522
 18 222225121212222111221222221121242622
 19 222225111212222121221212222121212522
 20 222225121212222122221222222223212421
 21 222124111212225122221222222221212422
 22 212224125212222122221212212221112422
 23 122224425212222122224121422221211422
 24 212226421212222121221222211121211522
 25 122225121212222121221222222221212622
 26 222124521212222522221222241521212522
 27 222225421242122122221222222221252522
 28 222225321212222322224221222221212322
 29 122225421112222122221222422121211522
 30 212124111242222122421222222221212522
 31 222225125242232122521225222121212622
 32 222225123112222122221222242223112522
 33 212225121212222122221222222221252522
 34 222225151212222522421122222121252522
 35 112225123212222122224222522221242522
 36 222225426212222122224222221121212522
 37 212224115212222522221222221221212642
 38 122215521212222112221222422221212522
 39 222225125212222151221211222221112522
 40 224225111112222122221222221221212442
 41 222225121212222121221225221221112522
 42 222125125512222121221222422221212522
 43 222124525242222112421222421226212422
 44 212124121212222122221122222221252422
 45 222224121212222122521222222226212322
 46 222125521112222321221211222221212522
 47 122215121212222122221211522121212522
 48 212114121212222122221122212221211422
 49 212224415212222122226221222521112521
 50 222215121214222521221222212121212522
 51 122215124242222422521222222221212522
 52 222125121262222522221212221121112522
 53 222225121212222122224222221121212622
 54 212225411215222122226221222221212522
 55 222224121212222122224222221221212522
 56 222115116212222122221222242221212522
 57 222215421212222122521222221221252322
 58 222224521242222122221222221221212522
 59 122225421212222522221222222121242522
 60 222224124212422122221112211111212422
 61 222225121212222122421212222221211522
 62 212224411212222122221215212211112422
 63 222215125242122122221222225211211422
 64 122224125212222112221222522221212525
 65 122226521212222522224222222221252522
 66 112224121212222151224222522221212422
 67 122224111212222422221221222221212422
 68 212125121242222122221221222221212522
 69 222224125242222121524222222226212521
 70 222224521242122122521122211511212522
 71 522225123212222121224122212221212321
 72 222224421212222122251251211221212422
 73 212225121242222122221222221221112522
 74 112224521212222522521522212221232522
 75 222225421242225122221222212211212422
 76 112114121212222122221222222221212522
 77 222224121212222122221222422121252522
 78 222225111212222122221221422221211322
 79 112225421212222122221222221221212522
 80 112225121212222122221222211221212422
 81 222125121242222112224222212121252422
 82 222225121212222122221121222123242522
 83 222225123212222122221222212226212422
 84 124245125242222422221222225121211522
 85 122225121212422122221222222121212522
 86 222124115242222122224222222221112522
 87 214114121212222112221221222221242522
 88 122225121212222122221112212221242522
 89 212214111242222122221122222221112522
 90 222225121212222122221222222221212522
 91 212225111242222125221242211221152622
 92 212225125212222122221125221221242422
 93 222216126212222121221522222221252422
 94 122225121212222121224222222121212322
 95 222114521242222122221222212221212522
 96 222125421212222122221222211521152522
 97 222215121542222122221222222221212522
 98 112245124212222122221112222221212522
 99 212215121212222122221224221221212522
100 122214111212222121221512225221112622
101 212225425212125122221222221211212522
102 222225421212222422224222222121212522
103 222225411262222521224222212226212522
104 122225124242222622421222422221212522
105 112224121212222521221222222211212522
106 222214124212222121221222221221252522
107 222226116242222122221222212121212521
108 222124121212222422221122222221212521
109 222124125242222412224122421221212622
110 112124121212222122221222212121252422
111 212125121212222122221122422221211422
112 262125121212222122221222421221211622
113 222215325212222122221222222221212322
114 222424121212122512221121222221152522
115 122225124242122422221222221221112422
116 222215111212222122221222222221242522
117 222224121242222122521222222111212522
118 222225121212222122221121222121212422
119 122125125112222121221222221221252322
120 222215121212225122221221421226112522
121 122224121212222122224221222521212322
122 222224121242222522224222221211242522
123 222124125242122112321221215221212522
124 222225121215222122221222212121212422
125 222126125112222122221122222221212322
126 212114425212222512421122212221111322
127 222225115212222122221222222221211522
128 222224511212125121221222222221212322
129 222125113212222122221122221221212422
130 112215125212222122221225242221212422
131 222125121212222122221222421221212522
132 212226121212122122521152211221211522
133 122224125112222122521122242223212422
134 212124111212222122221121221221212322
135 122225121212222122221112221221212522
136 122225121212222122521214222221212522
137 222125424214222422221522222221212522
138 222225121212222122221222222121242522
139 222225121212222521224211222221212522
140 122115121242222122221222241221212522
141 222224321212222122221251221221212522
142 222224421212222122524222222211212522
143 112214124212222121221222221121212422
144 222225121112222122221222221121252522
145 122225421242222122221222221221212522
146 122224121212222422221221222221212422
147 222224421242222121221211212221212421
148 122125121242222122221222222121211422
149 222225524212222112221221221221211522
150 212225421212222512221221412121212521
151 222225111142122122521222212221212522
152 212126121212222622221222222221212522
153 222225423212225422224212222221262522
154 222215121212225111224222241221212422
155 222125111242222122221221222221211322
156 212124121212222122221222222221211322
157 212125125212222512221221221513212622
158 212224121212222122221122221221212522
159 222125521212222122221222212226211521
160 222125121212222121221211212251212422
161 212124121242222122221112212411212522
162 222124121212222422221222226221211521
163 122224124212122122224221222221212522
164 222224115212222122221222422141412521
165 122124111212222122224222222121112322
166 122125124242222122221222222221252522
167 212225424242222121221222221221212522
168 212224121212222522224222222221242542
169 222225421212222122221222221121211421
170 122224121242222122221222222221232522
171 222224121112222322221222222223112422
172 212124111212222122224221222221212522
173 212225121212222121221221412221212521
174 122224524212222121221222411221212522
175 222225115242122322221222222121212421
176 212224121212422622421212422121112522
177 122125111242222122221222525211212322
178 222225125212222122221221222221212522
179 222225111212225122224262221226212322
180 122225511242222122224222221221112422
181 222224521212222112224222212221212322
182 222225114242222122221212222221252321
183 222224121242222122221221211221242322
184 222215111112222111221224222226252322
185 222215514245222522521122212221242422
186 222215125212222122221222212221212422
187 222225113212222122221221231121211522
188 212225125212222121221222222121212322
189 122124121212422122221222211221212522
190 212225424212222121521142241221212421
191 222124121112222112221522212211252422
192 222116121212222421221221221523212422
193 122226521242122122221222212221212322
194 222216125242222422221122221221242322
195 212224121212222122221211222221212522
196 222124121212222122226222222221211342
197 112224121242222121221222242221212621
198 122215121212222122224221211211212522
199 212225421212222422221222212121212421
200 212124125212222121521222222221111522
201 222215521212222122224122222221212422
202 212225121212422122221222212221212522
203 112125121214222621221122212221252525
204 222224121242222522221222221211212522
205 212124121212222122221222222121212422
206 122225124213222122221211222221252322
207 222125111212222122221222422121212322
208 222125115212222122221122412221212522
209 222124121512222122221222211221212422
210 222224121242222122321222521221212422
211 222225425112422122224121221221212322
212 222224111242222121221222222221212521
213 222226121212222112221222222221212422
214 212125521212222421221122223123212422
215 222125125242222122221222211121242522
216 222135111212222422221222221121252322
217 222225121212222422224222223221112322
218 222224121242222122221222412221112321
219 222224123212222122221212221226242522
220 112224521212122122221222222121212421
221 212225123142222122221222222221112421
222 212124126212222125221221212221112522
223 212225151212222122221221221221212522
224 112225125212222122221222221221212522
225 222224424242222112224221522121212422
226 222226121212225422221122222221112441
227 512225123242122122221222222121212522
228 222125424242222122221112421221212522
229 112224124212222122221222222221212422
230 214226115212222122224212222221212521
231 222225111212222422221222212123212522
232 212224121242222122221122211221112522
233 212125111212225421221222221121212422
234 212225525212222122224222422221212522
235 222224125212222422221222221521412422
236 212225423212222621221224412221212622
237 222124111212225422221122212121212522
238 222225121142222522221224222221212522
239 212225421212122122221121211221112422
240 222225111212222112221122221221142522
241 212124125212222122221122221521252521
242 122225121212222122521222521121212422
243 212115121212222122221212421121212322
244 514125124242422122226122422221212322
245 122125121212222121221222422221252522
246 122224521212222422221122221211241522
247 212225121212222121221222221221212522
248 112124121212222122221222221221242522
249 112224121242222121221222221221211422
250 212214421242222121221222211221112322
251 222125421212222122224522222221211542
252 222224511242222111224222222211212522
253 222225125242222122421222222221212322
254 212124123212222422221222421221212422
255 222225121242122422521222222121242422
256 226124321212222122221122242221112522
257 222224521212222122221222212221211322
258 212225125242222122221122222121212522
259 222224121212222112221222222221242422
260 222224111242422122221222221221212322
261 222224121112122422221222222211212522
262 212125551212222122224222422221242522
263 222225111212222122224215221221232422
264 212225121212222122221221221111242522
265 122226121212222122221221211121212622
266 112224121212222122221212225221212622
267 122124121212222122221222422221252522
268 222225521212222622221122221221242522
269 122224521212422122221221222221212521
270 212225121212222112221122322221212522
271 222125521212222422521212222121212522
272 122225121212122122221222212121212422
273 222115124212222122224222542221212522
274 112215325242222122224226422241212322
275 212225121212222122221112222221211322
276 222126121242222122231225222221212422
277 122224121242222122221224221221211522
278 222125521242222122221222222221212422
279 222124111212222522521221211221212522
280 122125121242222122251122222221212522
281 212224524112122122221222222221212522
282 212225425212222122421221422221212422
283 222226121242225122251222421221212522
284 222225121212222122221122222221252322
285 122226125212222622221122212123161422
286 222224121212222122221225222221212521
287 512126121312222121251221222251212522
288 122125521212222412221221221121212522
289 222225421212222125221221241221212542
290 212224121112122122221222222223212521
291 222126121212222121221222521221412522
292 122224125242225512221221222221212422
293 512224525242122312221222522221252522
294 522225121242222122221524212221212522
295 222114121212122522221222221221212421
296 222424123242222122221122221121212622
297 222225521212222422224222522121151622
298 222224121242122422221222512221212522
299 112225121212122121521222212211212622
300 122225123242122122221211222123212322
;

%mktmerge(design=sasuser.EntreeChDes, data=results, out=res2,
          nsets=&n, nalts=&m, setvars=choose1-choose&n)

proc print data=res2(obs=12); id subj set; by subj set; run;

proc summary data=res2 nway;
   class set brand price shelf micro x1 x2 x5 x6 x8 a1 a2 a5 a6 a8 c;
   output out=agg(drop=_type_);
   where w; /* exclude unavailable, w = 0 */
   run;

proc print; where set = 1; run;

proc transreg data=agg design=5000 nozeroconstant norestoremissing;
   model class(brand / zero='None')
         class(brand / zero='None' separators='' ' ') * identity(price)
         class(shelf micro / lprefix=5 0 zero='No' 'Stove')
         identity(x1 x2 x5 x6 x8) *
            class(brand / zero='None' separators=' ' ' on ')
         identity(a1 a2 a5 a6 a8) *
            class(brand / zero='None' separators=' ' ' on ') /
         lprefix=0;
   output out=coded(drop=_type_ _name_ intercept);
   id set c _freq_;
   label shelf = 'Shelf Talker'
         micro = 'Microwave';
   run;

proc phreg data=coded;
   strata set;
   model c*c(2) = &_trgind / ties=breslow;
   freq _freq_;
   run;

proc transreg data=agg design=5000 nozeroconstant norestoremissing;
   model class(brand / zero='None')
         class(brand / zero='None' separators='' ' ') * identity(price)
         class(shelf micro / lprefix=5 0 zero='No' 'Stove') /
         lprefix=0;
   output out=coded(drop=_type_ _name_ intercept);
   id set c _freq_;
   label shelf = 'Shelf Talker'
         micro = 'Microwave';
   run;

proc phreg data=coded;
   strata set;
   model c*c(2) = &_trgind / ties=breslow;
   freq _freq_;
   run;

data results;
   input Subj (choose1-choose&n) (1.) Age Income;
   datalines;
  1 222224155212222522221221222221212522  33 109
  2 222225421242222122221212222221211322  56 117
  3 212224521545222122221222221121112522  56  78
  4 212125121212222122221222421221212522  57 107
  5 222225125212222122521212222221212422  40 115
  6 222125523112222122224221212111242522  55  80
  7 222225121242222422221122221221112422  56 109
  8 222225124212222122221222522221212422  52 122
  9 122125121242222122221222222221242322  36 117
 10 212125125212222122221211222221112522  41 101
 11 222225121212222522221222222123212522  53 123
 12 122124121212222422221222221221212522  50 114
 13 122225125212222121221222222221212522  64 120
 14 222214123142222122221222241221211322  41  94
 15 222125121212222122221221221221212421  51 113
 16 212124425212222422224112422123212522  24  70
 17 212126525212222122524121421226212522  61  63
 18 222225121212222111221222221121242622  57 108
 19 222225111212222121221212222121212522  58 113
 20 222225121212222122221222222223212421  46 128
 21 222124111212225122221222222221212422  57 114
 22 212224125212222122221212212221112422  60 108
 23 122224425212222122224121422221211422  61  86
 24 212226421212222121221222211121211522  20  95
 25 122225121212222121221222222221212622  35 126
 26 222124521212222522221222241521212522  61  91
 27 222225421242122122221222222221252522  40 116
 28 222225321212222322224221222221212322  26 121
 29 122225421112222122221222422121211522  24  96
 30 212124111242222122421222222221212522  49 102
 31 222225125242232122521225222121212622  24  88
 32 222225123112222122221222242223112522  45 106
 33 212225121212222122221222222221252522  43 127
 34 222225151212222522421122222121252522  43  91
 35 112225123212222122224222522221242522  26  99
 36 222225426212222122224222221121212522  24 111
 37 212224115212222522221222221221212642  53  98
 38 122215521212222112221222422221212522  34 102
 39 222225125212222151221211222221112522  54  95
 40 224225111112222122221222221221212442  28  96
 41 222225121212222121221225221221112522  27 107
 42 222125125512222121221222422221212522  24  96
 43 222124525242222112421222421226212422  24  76
 44 212124121212222122221122222221252422  44 114
 45 222224121212222122521222222226212322  34 124
 46 222125521112222321221211222221212522  64  97
 47 122215121212222122221211522121212522  36  94
 48 212114121212222122221122212221211422  63 100
 49 212224415212222122226221222521112521  46  79
 50 222215121214222521221222212121212522  21  95
 51 122215124242222422521222222221212522  30  98
 52 222125121262222522221212221121112522  49  96
 53 222225121212222122224222221121212622  58 121
 54 212225411215222122226221222221212522  59  97
 55 222224121212222122224222221221212522  28 127
 56 222115116212222122221222242221212522  38 103
 57 222215421212222122521222221221252322  21 105
 58 222224521242222122221222221221212522  28 122
 59 122225421212222522221222222121242522  24 110
 60 222224124212422122221112211111212422  36  83
 61 222225121212222122421212222221211522  50 114
 62 212224411212222122221215212211112422  38  83
 63 222215125242122122221222225211211422  27  90
 64 122224125212222112221222522221212525  65  96
 65 122226521212222522224222222221252522  45 111
 66 112224121212222151224222522221212422  25  90
 67 122224111212222422221221222221212422  48 114
 68 212125121242222122221221222221212522  65 114
 69 222224125242222121524222222226212521  53  93
 70 222224521242122122521122211511212522  30  72
 71 522225123212222121224122212221212321  60  93
 72 222224421212222122251251211221212422  34  90
 73 212225121242222122221222221221112522  63 114
 74 112224521212222522521522212221232522  43  81
 75 222225421242225122221222212211212422  43 103
 76 112114121212222122221222222221212522  64 113
 77 222224121212222122221222422121252522  35 115
 78 222225111212222122221221422221211322  22 109
 79 112225421212222122221222221221212522  62 114
 80 112225121212222122221222211221212422  60 113
 81 222125121242222112224222212121252422  32  97
 82 222225121212222122221121222123242522  64 110
 83 222225123212222122221222212226212422  33 124
 84 124245125242222422221222225121211522  23  68
 85 122225121212422122221222222121212522  39 114
 86 222124115242222122224222222221112522  51 103
 87 214114121212222112221221222221242522  26  89
 88 122225121212222122221112212221242522  35 107
 89 212214111242222122221122222221112522  21 101
 90 222225121212222122221222222221212522  34 139
 91 212225111242222125221242211221152622  34  73
 92 212225125212222122221125221221242422  60  97
 93 222216126212222121221522222221252422  58 105
 94 122225121212222121224222222121212322  32 115
 95 222114521242222122221222212221212522  60 109
 96 222125421212222122221222211521152522  46  90
 97 222215121542222122221222222221212522  63 115
 98 112245124212222122221112222221212522  32  96
 99 212215121212222122221224221221212522  60 107
100 122214111212222121221512225221112622  65  77
101 212225425212125122221222221211212522  53  90
102 222225421212222422224222222121212522  61 116
103 222225411262222521224222212226212522  26  94
104 122225124242222622421222422221212522  59  94
105 112224121212222521221222222211212522  26 107
106 222214124212222121221222221221252522  55 109
107 222226116242222122221222212121212521  40 104
108 222124121212222422221122222221212521  36 114
109 222124125242222412224122421221212622  56  81
110 112124121212222122221222212121252422  33 101
111 212125121212222122221122422221211422  59 101
112 262125121212222122221222421221211622  27  97
113 222215325212222122221222222221212322  47 124
114 222424121212122512221121222221152522  43  84
115 122225124242122422221222221221112422  61  97
116 222215111212222122221222222221242522  26 120
117 222224121242222122521222222111212522  65 109
118 222225121212222122221121222121212422  33 119
119 122125125112222121221222221221252322  22  97
120 222215121212225122221221421226112522  28  84
121 122224121212222122224221222521212322  52 110
122 222224121242222522224222221211242522  47 105
123 222124125242122112321221215221212522  29  73
124 222225121215222122221222212121212422  64 114
125 222126125112222122221122222221212322  44 116
126 212114425212222512421122212221111322  49  61
127 222225115212222122221222222221211522  46 120
128 222224511212125121221222222221212322  64 103
129 222125113212222122221122221221212422  48 109
130 112215125212222122221225242221212422  47  90
131 222125121212222122221222421221212522  56 114
132 212226121212122122521152211221211522  59  77
133 122224125112222122521122242223212422  23  87
134 212124111212222122221121221221212322  30 101
135 122225121212222122221112221221212522  35 113
136 122225121212222122521214222221212522  43 102
137 222125424214222422221522222221212522  43  93
138 222225121212222122221222222121242522  49 127
139 222225121212222521224211222221212522  35 108
140 122115121242222122221222241221212522  45  96
141 222224321212222122221251221221212522  57 110
142 222224421212222122524222222211212522  33 110
143 112214124212222121221222221121212422  35  95
144 222225121112222122221222221121252522  36 114
145 122225421242222122221222221221212522  23 115
146 122224121212222422221221222221212422  39 121
147 222224421242222121221211212221212421  51  96
148 122125121242222122221222222121211422  56 108
149 222225524212222112221221221221211522  40 102
150 212225421212222512221221412121212521  56  77
151 222225111142122122521222212221212522  34  95
152 212126121212222622221222222221212522  39 122
153 222225423212225422224212222221262522  45  96
154 222215121212225111224222241221212422  21  84
155 222125111242222122221221222221211322  46 109
156 212124121212222122221222222221211322  39 121
157 212125125212222512221221221513212622  61  74
158 212224121212222122221122221221212522  40 119
159 222125521212222122221222212226211521  39 103
160 222125121212222121221211212251212422  36  94
161 212124121242222122221112212411212522  26  83
162 222124121212222422221222226221211521  42 103
163 122224124212122122224221222221212522  24 109
164 222224115212222122221222422141412521  32  79
165 122124111212222122224222222121112322  41 103
166 122125124242222122221222222221252522  64 110
167 212225424242222121221222221221212522  59 103
168 212224121212222522224222222221242542  28 105
169 222225421212222122221222221121211421  36 108
170 122224121242222122221222222221232522  52 123
171 222224121112222322221222222223112422  47 118
172 212124111212222122224221222221212522  33 108
173 212225121212222121221221412221212521  35  94
174 122224524212222121221222411221212522  62  90
175 222225115242122322221222222121212421  42  98
176 212224121212422622421212422121112522  23  73
177 122125111242222122221222525211212322  46  85
178 222225125212222122221221222221212522  21 127
179 222225111212225122224262221226212322  26  94
180 122225511242222122224222221221112422  31  97
181 222224521212222112224222212221212322  62 117
182 222225114242222122221212222221252321  56 105
183 222224121242222122221221211221242322  48 111
184 222215111112222111221224222226252322  45  86
185 222215514245222522521122212221242422  22  62
186 222215125212222122221222212221212422  51 120
187 222225113212222122221221231121211522  63  92
188 212225125212222121221222222121212322  42 115
189 122124121212422122221222211221212522  64 101
190 212225424212222121521142241221212421  29  61
191 222124121112222112221522212211252422  46  89
192 222116121212222421221221221523212422  28  86
193 122226521242122122221222212221212322  34 111
194 222216125242222422221122221221242322  48 100
195 212224121212222122221211222221212522  57 119
196 222124121212222122226222222221211342  28 111
197 112224121242222121221222242221212621  58  97
198 122215121212222122224221211211212522  24  94
199 212225421212222422221222212121212421  57 102
200 212124125212222121521222222221111522  51  89
201 222215521212222122224122222221212422  63 115
202 212225121212422122221222212221212522  41 114
203 112125121214222621221122212221252525  34  66
204 222224121242222522221222221211212522  29 115
205 212124121212222122221222222121212422  37 120
206 122225124213222122221211222221252322  60 100
207 222125111212222122221222422121212322  51 109
208 222125115212222122221122412221212522  63  95
209 222124121512222122221222211221212422  61 108
210 222224121242222122321222521221212422  60 105
211 222225425112422122224121221221212322  47  87
212 222224111242222121221222222221212521  56 114
213 222226121212222112221222222221212422  25 133
214 212125521212222421221122223123212422  37  81
215 222125125242222122221222211121242522  32  97
216 222135111212222422221222221121252322  54  93
217 222225121212222422224222223221112322  26 113
218 222224121242222122221222412221112321  43 104
219 222224123212222122221212221226242522  54 112
220 112224521212122122221222222121212421  32 101
221 212225123142222122221222222221112421  29 104
222 212124126212222125221221212221112522  56  90
223 212225151212222122221221221221212522  41 107
224 112225125212222122221222221221212522  23 114
225 222224424242222112224221522121212422  50  87
226 222226121212225422221122222221112441  40  91
227 512225123242122122221222222121212522  23  98
228 222125424242222122221112421221212522  62  85
229 112224124212222122221222222221212422  64 121
230 214226115212222122224212222221212521  37  91
231 222225111212222422221222212123212522  38 110
232 212224121242222122221122211221112522  46 101
233 212125111212225421221222221121212422  43  83
234 212225525212222122224222422221212522  54 104
235 222224125212222422221222221521412422  40  98
236 212225423212222621221224412221212622  27  83
237 222124111212225422221122212121212522  45  89
238 222225121142222522221224222221212522  61 110
239 212225421212122122221121211221112422  31  88
240 222225111212222112221122221221142522  29 101
241 212124125212222122221122221521252521  31  83
242 122225121212222122521222521121212422  46  95
243 212115121212222122221212421121212322  52  89
244 514125124242422122226122422221212322  41  59
245 122125121212222121221222422221252522  60 102
246 122224521212222422221122221211241522  39  90
247 212225121212222121221222221221212522  33 119
248 112124121212222122221222221221242522  27 108
249 112224121242222121221222221221211422  47 101
250 212214421242222121221222211221112322  57  91
251 222125421212222122224522222221211542  40  92
252 222224511242222111224222222211212522  26  97
253 222225125242222122421222222221212322  35 118
254 212124123212222422221222421221212422  27  99
255 222225121242122422521222222121242422  35  98
256 226124321212222122221122242221112522  33  93
257 222224521212222122221222212221211322  43 122
258 212225125242222122221122222121212522  20 108
259 222224121212222112221222222221242422  36 127
260 222224111242422122221222221221212322  62 111
261 222224121112122422221222222211212522  20 114
262 212125551212222122224222422221242522  47  86
263 222225111212222122224215221221232422  46  98
264 212225121212222122221221221111242522  38 101
265 122226121212222122221221211121212622  48 108
266 112224121212222122221212225221212622  50 108
267 122124121212222122221222422221252522  22 109
268 222225521212222622221122221221242522  28 110
269 122224521212422122221221222221212521  48 102
270 212225121212222112221122322221212522  47 109
271 222125521212222422521212222121212522  47  96
272 122225121212122122221222212121212422  52 113
273 222115124212222122224222542221212522  35  92
274 112215325242222122224226422241212322  49  66
275 212225121212222122221112222221211322  42 114
276 222126121242222122231225222221212422  37 106
277 122224121242222122221224221221211522  45 102
278 222125521242222122221222222221212422  49 122
279 222124111212222522521221211221212522  49  89
280 122125121242222122251122222221212522  33 102
281 212224524112122122221222222221212522  58 109
282 212225425212222122421221422221212422  64  92
283 222226121242225122251222421221212522  21  92
284 222225121212222122221122222221252322  46 128
285 122226125212222622221122212123161422  38  82
286 222224121212222122221225222221212521  38 120
287 512126121312222121251221222251212522  62  67
288 122125521212222412221221221121212522  40  89
289 222225421212222125221221241221212542  28  85
290 212224121112122122221222222223212521  64 109
291 222126121212222121221222521221412522  42  96
292 122224125242225512221221222221212422  55  92
293 512224525242122312221222522221252522  37  70
294 522225121242222122221524212221212522  33  91
295 222114121212122522221222221221212421  56 101
296 222424123242222122221122221121212622  41  99
297 222225521212222422224222522121151622  23  87
298 222224121242122422221222512221212522  50 103
299 112225121212122121521222212211212622  41  89
300 122225123242122122221211222123212322  38  95
;

%mktmerge(design=sasuser.EntreeChDes(drop=x1--x8 a1--a8), data=results,
          out=res2, nsets=&n, nalts=&m, setvars=choose1-choose&n)

proc print data=res2;
   by subj set; id subj set;
   where (subj = 1 and set = 1) or
         (subj = 2 and set = 2) or
         (subj = 3 and set = 3) or
         (subj = 300 and set = 36);
   run;

proc transreg data=res2 design=5000 nozeroconstant norestoremissing;
   model class(brand / zero='None')
         identity(age income) * class(brand / zero='None' separators='' ', ')
         class(brand / zero='None' separators='' ' ') * identity(price)
         class(shelf micro / lprefix=5 0 zero='No' 'Stove') /
         lprefix=0 order=data;

   output out=code(drop=_type_ _name_ intercept);
   id subj set c w;
   label shelf = 'Shelf Talker'
         micro = 'Microwave';
   run;

data coded(drop=w); set code; where w; run; /* exclude unavailable */

proc print data=coded(obs=4) label;
   id brand price;
   var BrandClient -- BrandPrivate Shelf Micro c;
   run;

proc print data=coded(obs=4 drop=Age) label;
   id brand price;
   var Age:;
   run;

proc print data=coded(obs=4 drop=Income) label;
   id brand price;
   var Income:;
   run;

proc print data=coded(obs=4) label;
   id brand price;
   var BrandClientPrice -- BrandPrivatePrice;
   format BrandClientPrice -- BrandPrivatePrice best4.;
   run;

proc phreg data=coded brief;
   model c*c(2) = &_trgind / ties=breslow;
   strata subj set;
   run;

%phchoice(off)