After cleaning up the quotes, etc., I added a restrictions macro before the mktex step. In it, I count (using Boolean logic where true = 1 and false = 0) the number of pairs across alternatives that are the same. Then if 3 or more are the same, I set badness to the number that are the same. Now when I specify this macro in mktex, it will insert the macro code deep into mktex, ensuring that mktex will try its best to eliminate combinations that you don't want. Note that it is easy to make a mistake and specify restrictions that cannot possibly be satisfied. It is also possible to specify restrictions that are valid, but provide the macro insufficient direction on how to get to the desired result. Hence, I quantified the badness, how far we were from satisfying the condition, rather than a simple binary badness. If you have further questions, ping me, @WarrenKuhfeld, and I will try my best to answer. Also, as was previously pointed out, it is best to spell out things like DCE in your title. If I had seen it in the group, I might not have realized that you were asking a question I could answer. I would have immediately known if I had seen discrete choice. Good luck.
%mktruns(4 2 2 4 4 2 2 4) /* factor level list for all attrs and alts */
%macro res;
_sum = (x1 = x5) + (x2 = x6) + (x3 = x7) + (x4 = x8);
bad = 0;
if _sum >= 3 then bad = _sum;
%mend;
%mktex(4 2 2 4 4 2 2 4, /* factor level list for all attrs and alts */
restrictions=res,
n=64, /* number of choice sets */
seed=17) /* random number seed
%mktblock(data=randomized, /* block randomized design */
nblocks=2, /* create 2 blocks of 32 choice sets */
out=blocked, /* output data set for blocked design */
seed=17) /* random number seed */
data key;
input
Brand $ Knd $ Omg $ Mrk $ Price $; datalines;
Alt1 x1 x2 x3 x4
Alt2 x5 x6 x7 x8
None . . . . .
;
%mktroll(design=blocked, /* make choice design from blocked */
/* linear arrangement from %mktblock */
key=key, /* use rules in KEY data set */
alt=brand, /* alternative name variable is Place */
out=work.food64, /* permanent data set for results */
keep=block) /* keep the blocking variable */
proc format;
value knd 1 = '%5' 2 = '%10' 3 = '%15' 4 = '%20' . = ' ';
value omg 1 = 'no' 2 = 'yes' . = ' ';
value mrk 1 = 'no' 2 = 'yes' . = ' ';
value price 1 = $30 2 = $40 3 = $50 4 = $60 . = ' ';
run;
data work.food64;
set work.food64;
format knd knd. omg omg. mrk mrk. price price.;
run;
proc print data=work.food64(obs=192);
by set; id set;
run;
... View more