/****************************************************************/ /* S A S S A M P L E C O D E */ /* */ /* NAME: TS722I */ /* TITLE: The Macros */ /* PRODUCT: STAT */ /* SYSTEM: ALL */ /* KEYS: marketing research */ /* PROCS: PHREG, TRANSREG, OPTEX, FACTEX, PLAN, IML */ /* DATA: */ /* */ /* SUPPORT: saswfk UPDATE: 01Jan2005 */ /* REF: TS-722I The Macros */ /* MISC: This file contains all of the sample code for */ /* the "The Macros" report, */ /* the 01Jan2005 edition, for SAS 9.1. This code */ /* should work fine in SAS 8.2 and SAS 9.0 as well. */ /* */ /* 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 */ /* MktBlock Block an Experimental Design */ /* 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 */ /* 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 */ /* */ /****************************************************************/ %mktex( 2 3 ** 7, n=18 ) ****************** Begin ChoicEff Macro Example Code ******************; options ls=80 ps=60 nonumber nodate; title; %mktex(3 ** 3, n=3**3, seed=238) %mktlab(int=f1-f3) proc print; run; %choiceff(data=final, model=class(x1-x3), nsets=9, flags=f1-f3, beta=zero, seed=145, maxiter=100) proc print; var x1-x3; id set; by set; run; * Cyclic (Optimal) Design; data x(keep=f1-f3 x1-x3); retain f1-f3 1; d1 = ceil(_n_ / 3); d2 = mod(_n_ - 1, 3) + 1; input d3 @@; do i = -1 to 1; x1 = mod(d1 + i, 3) + 1; x2 = mod(d2 + i, 3) + 1; x3 = mod(d3 + i, 3) + 1; output; end; datalines; 1 2 3 3 1 2 2 3 1 ; proc print data=x; var x: f:; run; %choiceff(data=x, model=class(x1-x3), nsets=9, flags=f1-f3, beta=zero, init=x, initvars=x1-x3, intiter=0) %mktex(3 ** 9, n=2187) data key; input (x1-x3) ($); datalines; x1 x2 x3 x4 x5 x6 x7 x8 x9 ; %mktroll(design=design, key=key, out=rolled) %choiceff(data=rolled, model=class(x1-x3), nsets=9, nalts=3, beta=zero, seed=17) %mktex(3 ** 4, n = 3**4) %mktlab(data=design, vars=x1-x3 Brand) data full(drop=i); set final; array f[3]; do i = 1 to 3; f[i] = (brand eq i); end; run; proc print data=full(obs=9); run; %choiceff(data=full, seed=151, model=class(brand brand*x1 brand*x2 brand*x3 / zero=' '), nsets=15, flags=f1-f3, beta=zero, converge=1e-12); %choiceff(data=full, init=best(keep=index), drop=brand3, seed=522, model=class(brand brand*x1 brand*x2 brand*x3 / zero=' '), nsets=15, flags=f1-f3, beta=zero, converge=1e-12); %mktex(3 ** 9, n=2187, seed=121) data key; input (Brand x1-x3) ($); datalines; 1 x1 x2 x3 2 x4 x5 x6 3 x7 x8 x9 ; %mktroll(design=design, key=key, alt=brand, out=rolled) %choiceff(data=rolled, nsets=15, nalts=3, model=class(brand) class(brand*x1 brand*x2 brand*x3 / effects zero=' ')) %choiceff(data=rolled, nsets=15, nalts=3, n=100, seed=462, beta=1 2 -0.5 0.5 -0.75 0.75 -1 1 -0.5 0.5 -0.75 0.75 -1 1 -0.5 0.5 -0.75 0.75 -1 1, model=class(brand) class(brand*x1 brand*x2 brand*x3 / effects zero=' ')) %mktex(3 ** 5, n=3**5) data key; input (Brand Price) ($); datalines; 1 x1 2 x2 3 x3 4 x4 5 x5 . . ; %mktroll(design=design, key=key, alt=brand, out=rolled, keep=x1-x5) proc print; by set; id set; where set in (1, 48, 101, 243); run; %choiceff(data=rolled, seed=17, model=class(brand brand*price / zero=none) identity(x1-x5) * class(brand / zero=none), nsets=20, nalts=6, beta=zero); %choiceff(data=rolled, seed=17, model=class(brand brand*price / zero=' ') identity(x1-x5) * class(brand / zero=none), drop=x1Brand1 x2Brand2 x3Brand3 x4Brand4 x5Brand5, nsets=20, nalts=6, beta=zero); data cand; array n[10] _temporary_ (8 8 6 6 6 4 4 4 4 4); retain f1-f11 0; array f[11]; do Brand = 1 to 10; f[brand] = 1; do Price = 1 to n[brand]; output; end; f[brand] = 0; end; brand = .; price = .; f11 = 1; output; run; proc print; id brand price; run; %choiceff(data=cand, seed=462, model=class(brand / zero=none) class(brand*price / zero=' '), nsets=24, flags=f1-f11, beta=zero) %choiceff(data=cand, seed=462, model=class(brand / zero=none) class(brand*price / zero=' '), nsets=24, flags=f1-f11, beta=zero, drop= brand3price6 brand3price7 brand4price6 brand4price7 brand5price6 brand5price7 brand6price4 brand6price5 brand6price6 brand6price7 brand7price4 brand7price5 brand7price6 brand7price7 brand8price4 brand8price5 brand8price6 brand8price7 brand9price4 brand9price5 brand9price6 brand9price7 brand10price4 brand10price5 brand10price6 brand10price7 ); proc print data=best(obs=22); id set; by set; var brand price; run; proc transpose data=best out=lin(keep=x1-x10) prefix=x; var price; by set; run; proc print; run; data key; input x1-x10; datalines; 0.89 0.94 0.99 0.89 1.04 0.89 0.99 0.94 1.09 1.14 0.94 0.99 1.04 0.94 1.09 0.99 1.09 0.99 1.14 1.19 0.99 1.04 1.09 0.99 1.14 1.09 1.19 1.14 1.19 1.24 1.04 1.09 1.14 1.04 1.19 1.19 1.29 1.19 1.24 1.29 1.09 1.14 1.19 1.09 1.24 . . . . . 1.14 1.19 1.24 1.14 1.29 . . . . . 1.19 1.24 . . . . . . . . 1.24 1.29 . . . . . . . . ; proc print; run; %mktlab(data=lin, key=key, out=final) %mktkey(x1-x10) data key; if _n_ le 10 then Brand = put(_n_, 2.); input Price $ @@; datalines; x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 . ; proc print; run; %mktroll(design=final, alt=brand, key=key, out=sasuser.prices) proc print data=sasuser.prices(obs=22); id set; by set; var brand price; run; ******************* Begin MktAllo Macro Example Code ******************; options ls=80 ps=60 nonumber nodate; title; data allocs2; input Brand $ 1-8 Price $ Count Set; datalines; . . 0 1 Brand 1 $50 103 1 Brand 2 $75 58 1 Brand 3 $50 318 1 Brand 4 $100 99 1 Brand 5 $100 54 1 Brand 6 $100 83 1 Brand 7 $75 71 1 Brand 8 $75 58 1 Brand 9 $75 100 1 Brand 10 $50 56 1 . . 10 2 Brand 1 $100 73 2 Brand 2 $100 76 2 Brand 3 $100 342 2 Brand 4 $50 55 2 Brand 5 $75 50 2 Brand 6 $100 77 2 Brand 7 $75 95 2 Brand 8 $100 71 2 Brand 9 $50 72 2 Brand 10 $100 79 2 ; proc print; run; %mktallo(data=allocs2, out=allocs3, nalts=11, vars=set brand price, freq=Count) proc print; run; ******************* Begin MktBal Macro Example Code *******************; options ls=80 ps=60 nonumber nodate; title; %mktbal(2 2 3 3 3, n=18, seed=151) %mkteval; %mktbal(2 3 4 5 6 7 8 9 10, n=120, options=progress, seed=17) %mktbal(2 3 4 5 6 7 8 9 10, n=120, options=progress, seed=17, maxstarts=1, maxiter=1, maxtries=1) ****************** Begin MktBlock Macro Example Code ******************; options ls=80 ps=60 nonumber nodate; title; %mktex(3 ** 7, n=27, seed=350) %mktlab(vars=x1-x6 Block) %mktex(3 ** 6, n=27, seed=350) %mktblock(data=randomized, nblocks=3, seed=377, maxiter=50) %mktex(3 ** 6, n=3**6) * Create an efficient choice design; data key; input (x1-x3) ($); datalines; x1 x2 x3 x4 x5 x6 ; %mktroll(design=design, key=key, out=out) %choiceff(data=out, model=class(x1-x3), nsets=18, nalts=2, beta=zero, options=nodups, seed=151) * Block the choice design. Ask for 2 blocks; %mktblock(data=best, nalts=2, nblocks=2, factors=x1-x3, seed=472) ******************* Begin MktDes Macro Example Code *******************; options ls=80 ps=60 nonumber nodate; title; %mktdes(factors=x1-x2=2 x3-x5=3, n=18) *---2 two-level factors and 3 three-level factors in 18 runs---; %mktdes(factors=x1-x2=2 x3-x5=3, n=18, maxiter=500) %mktdes(factors=x1-x10=2) %mktdes(factors=x1-x5=2 x6-x10=3 x11-x15=5) %mktdes(factors=x1-x5=2 x6-x10=3(3)) %mktdes(step=1, factors=x1-x3=2, n=30, run=factex) %mktdes(step=2, factors=x4-x6=3, n=30, run=factex) %mktdes(step=3, factors=x7-x9=5, n=30, run=factex optex, otherint=x1*x4) %mktdes(factors=x1-x3=2 x4-x6=3 x7-x9=5, n=30) %mktdes(step=1, factors=x1-x3=2, n=30, run=factex) %mktdes(step=2, factors=x4-x6=3, n=30, run=factex) %mktdes(step=3, factors=x7-x9=5, n=30, run=factex optex) %mktex(2 2 2 3 3 3 5 5 5, n=30) proc optex data=Cand3; class x1-x3 x4-x6 x7-x9 / param=orthref; model x1-x3 x4-x6 x7-x9 ; generate n=30 iter=10 keep=5 method=m_fedorov; output out=Design; run; quit; ******************* Begin MktDups Macro Example Code ******************; options ls=80 ps=60 nonumber nodate; title; %mktex(3 ** 9, n=27, seed=424) data key; input (Brand x1-x3) ($); datalines; Acme x1 x2 x3 Ajax x4 x5 x6 Widgit x7 x8 x9 ; %mktroll(design=randomized, key=key, alt=brand, out=cand) %choiceff(data=cand, model=class(brand x1-x3), seed=420, nsets=18, nalts=3, beta=zero) proc freq; tables set; run; %mktdups(branded, data=best, factors=brand x1-x3, nalts=3, out=out) proc freq; tables set; run; %mktex(2 ** 5, n=2**5, seed=109) %mktlab(int=f1-f4) %choiceff(data=final, model=class(x1-x5), seed=93, nsets=42, flags=f1-f4, beta=zero) %mktdups(generic, data=best, factors=x1-x5, nalts=4, out=out) proc print data=best; var x1-x5; id set; by set; where set in (2, 25, 39); run; %mktex(2 ** 6, n=2**6) data key; input (x1-x2) ($) @@; datalines; x1 x2 x3 x4 x5 x6 ; %mktroll(design=design, key=key, out=cand) %mktdups(generic, data=cand, factors=x1-x2, nalts=3, out=out) proc print; by set; id set; run; %mktex( 3 ** 3 2 ** 2, n=19, seed=121) %mktdups(linear, factors=x1-x5) ******************* Begin MktEval Macro Example Code ******************; options ls=80 ps=60 nonumber nodate; title; %mktex(2 2 3 ** 6, n=18, unbalanced=0, seed=289) %mkteval; ******************** Begin MktEx Macro Example Code *******************; options ls=80 ps=60 nonumber nodate; title; %mktex( 2 ** 5 3 ** 4 5 5 5 6 6, n=60 ) data x; length Method $ 30; do n = 4 to 10000 by 4; HadSize = n; method = ' '; do while(mod(hadsize, 8) eq 0); hadsize = hadsize / 2; end; link paley; if method eq ' ' and hadsize le 256 then method = 'Williamson'; if method eq ' ' and hadsize gt 256 then do; do while(hadsize lt n and method eq ' '); hadsize = hadsize * 2; link paley; end; end; if method eq ' ' and hadsize = 428 then method = 'Kharaghania and Tayfeh-Rezaiea'; if method ne ' ' then do; Change = n - lag(n); output; end; end; return; paley:; ispm1 = 1; ispm2 = mod(hadsize / 2, 4) eq 2; h = hadsize - 1; do i = 3 to sqrt(hadsize) by 2 while(ispm1); ispm1 = mod(h, i); end; h = hadsize / 2 - 1; do i = 3 to sqrt(hadsize / 2) by 2 while(ispm2); ispm2 = mod(h, i); end; if ispm1 then method = 'Paley 1'; else if ispm2 then method = 'Paley 2'; return; run; options ps=11000; proc print label noobs; label hadsize = 'Reduced Hadamard Matrix Size'; var n hadsize method change; run; %mktex( n=36 ) %mktruns( 4 2 ** 5 3 ** 5 ) %mktex(2 ** 5, interact=@2, n=32) %mktex(2 ** 5, interact=1|2|3|4|5@2, n=32) %mktex(4 ** 12, n=48, partial=4, seed=205, maxdesigns=1) %mktlab(values=. 1 2 3, nfill=99) options missing=' '; proc print data=final(obs=10); run; options missing='.'; %macro restrict; bad = (x1 = x2) + (x2 = x3) + (x3 = x4) + (x4 = x5); %mend; %let m = 5; data ex; do i = 1 to &m; do j = i + 1 to &m; output; end; end; run; proc print noobs; run; %macro sumres; allone = 0; oneone = 0; alltwo = 0; do k = 1 to 22; if (x[k] = 1 & x[k+22] = 1) then allone = allone + 1; else if (x[k] = 1 | x[k+22] = 1) then oneone = oneone + 1; else if (x[k] = 2 & x[k+22] = 2) then alltwo = alltwo + 1; end; bad = 100 # (^(5 <= allone & allone <= 9)) # abs(allone - 7) + 10 # (^(5 <= oneone & oneone <= 9)) # abs(oneone - 7) + (^(5 <= alltwo & alltwo <= 9)) # abs(alltwo - 7); %mend; %mktex(3 ** 50, n=135, optiter=0, tabiter=0, maxdesigns=1, restrictions=sumres, seed=289, options=resrep) %mktkey(x1-x50) data key; input (x1-x25) ($); datalines; x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 x16 x17 x18 x19 x20 x21 x22 x45 x46 x47 x23 x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41 x42 x43 x44 x48 x49 x50 ; %mktroll(design=design, key=key, out=chdes) proc print; by set; id set; where set le 2 or set ge 134; run; ******************* Begin MktKey Macro Example Code *******************; options ls=80 ps=60 nonumber nodate; title; %mktkey(x1-x15) data key; input (x1-x5) ($); datalines; x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12 x13 x14 x15 . . . . . ; %mktkey(5 10) %mktkey(5 10 t) ******************* Begin MktLab Macro Example Code *******************; options ls=80 ps=60 nonumber nodate; title; %mktex(n=12, options=nosort) proc print noobs; run; %mktex(n=12, options=nosort, levels=i int) %mktex(n=12, options=nosort) %mktlab(data=design, values=1 -1, int=Had0, prefix=Had) %mktlab(data=design, values=1 -1, int=Had0, prefix=Had) proc print noobs; run; data key; array Had[11]; input Had1 @@; do i = 2 to 11; Had[i] = Had1; end; drop i; datalines; 1 -1 ; proc print data=key; run; %mktlab(data=design, key=key, int=Had0) data randomized; input x1-x8 @@; datalines; 4 2 1 1 1 2 2 2 2 1 1 2 1 3 1 3 3 4 2 2 1 3 2 3 4 3 2 1 3 2 2 3 4 1 2 1 1 1 1 1 2 4 1 2 1 2 1 1 1 2 1 2 3 3 2 1 2 2 2 2 2 2 2 3 1 4 2 1 1 2 2 2 3 2 2 1 3 1 2 1 1 4 1 2 2 3 1 2 1 3 2 2 1 3 1 1 3 2 1 2 2 1 2 3 3 4 1 1 3 1 1 3 4 1 2 2 2 1 2 1 2 3 2 1 2 3 2 2 2 1 2 1 3 3 1 3 4 2 2 2 1 3 1 2 2 4 2 2 3 1 1 2 3 1 2 2 3 2 1 2 3 3 1 1 2 3 1 1 4 4 2 1 2 2 1 3 1 1 1 1 3 2 1 2 4 3 1 2 3 3 2 2 1 2 2 1 2 1 1 3 1 3 1 1 1 1 2 3 ; data key; missing N; input Client ClientLineExtension ClientMicro $ ShelfTalker $ Regional Private PrivateMicro $ NationalLabel; format _numeric_ dollar5.2; datalines; 1.29 1.39 micro Yes 1.99 1.49 micro 1.99 1.69 1.89 stove No 2.49 2.29 stove 2.39 2.09 2.39 . . N N . N N N . . . . . . ; %mktlab(key=key) proc sort; by shelftalker; run; proc print; by shelftalker; run; %mktex(n=36, seed=420) data key; array x[23] two1-two11 thr1-thr12; input two1 thr1; do i = 2 to 11; x[i] = two1; end; do i = 13 to 23; x[i] = thr1; end; drop i; datalines; -1 -1 1 0 . 1 ; %mktlab(key=key) proc print data=key noobs; var two:; run; proc print data=key noobs; var thr:; run; proc print data=final(obs=5) noobs; var two:; run; proc print data=final(obs=5) noobs; var thr:; run; %mktex(n=18, seed=396) %mktblock(nblocks=2, factors=x1-x4, seed=292) data key; input Brand $ Price Size; format price dollar5.2; datalines; Acme 1.49 6 Apex 1.79 8 . 1.99 12 ; %mktlab(data=blocked, key=key) %mktex(3 ** 15, n=36, seed=17, maxtime=0) %mktblock(data=randomized, nblocks=2, factors=x1-x15, seed=448) %macro lab; label X1 = 'Hawaii, Accommodations' X2 = 'Alaska, Accommodations' X3 = 'Mexico, Accommodations' X4 = 'California, Accommodations' X5 = 'Maine, Accommodations' X6 = 'Hawaii, Scenery' X7 = 'Alaska, Scenery' X8 = 'Mexico, Scenery' X9 = 'California, Scenery' X10 = 'Maine, Scenery' X11 = 'Hawaii, Price' X12 = 'Alaska, Price' X13 = 'Mexico, Price' X14 = 'California, Price' X15 = 'Maine, Price'; format x11-x15 dollar5.; %mend; data key; length x1-x5 $ 16 x6-x10 $ 8 x11-x15 8; input x1 & $ x6 $ x11; x2 = x1; x3 = x1; x4 = x1; x5 = x1; x7 = x6; x8 = x6; x9 = x6; x10 = x6; x12 = x11; x13 = x11; x14 = x11; x15 = x11; datalines; Cabin Mountains 999 Bed & Breakfast Lake 1249 Hotel Beach 1499 ; %mktlab(data=blocked, key=key, labels=lab) proc contents p; ods select position; run; %mktex(3 ** 4, n=18, seed=205) %macro labs; label x1 = 'Sploosh' x2 = 'Plumbob' x3 = 'Platter' x4 = 'Moosey'; format x1-x4 dollar5.2; %mend; %mktlab(values=1.49 1.99 2.49, labels=labs) proc print label; run; %mktex(3 ** 4, n=18, seed=205) %mktlab(values=1.49 1.99 2.49, vars=Sploosh Plumbob Platter Moosey, statements=format Sploosh Plumbob Platter Moosey dollar5.2) proc print; run; ****************** Begin MktMerge Macro Example Code ******************; options ls=80 ps=60 nonumber nodate; title; %mktmerge(design=rolled, data=results, out=res2, nsets=18, nalts=5, setvars=choose1-choose18) %mktmerge(design=rolled, data=results, out=res2, blocks=form, nsets=18, nalts=5, setvars=choose1-choose18) ******************* Begin MktOrth Macro Example Code ******************; options ls=80 ps=60 nonumber nodate; title; %mktorth(maxn=100, maxlev=6) %mktorth(maxlev=144, options=512) %mktorth(maxlev=144) proc print data=mktdeslev(where=(n le 12 or n eq 512 and x2 le 4)); var design reference; id n; by n; run; proc print data=mktdeslev(where=(n le 12)); var design reference x1-x6; id n; by n; run; %mktorth(maxn=100) proc print data=mktdeslev noobs; where x2 ge 5 and x3 ge 5 and x4 ge 1; var n design reference; run; %mktorth(range=12 le n le 20) proc print; id n; by n; run; %mktorth(range=n=36, options=lineage) proc print noobs; where index(design, '2 ** 11') and index(design, '3 ** 12'); run; ******************* Begin MktPPro Macro Example Code *******************; options ls=80 ps=60 nonumber nodate; title; %mktex(2 4 2 2 2, n=8) proc print; run; data design; set design; drop x2; run; proc iml; b = { 1 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 6 7 , 2 5 8 11 14 5 6 7 10 5 6 7 9 5 6 7 8 9 10 8 , 3 6 9 12 15 8 12 9 13 13 8 10 11 10 9 11 12 12 11 13 , 4 7 10 13 16 11 14 15 16 15 16 12 14 14 13 16 15 16 15 14 }`; create b from b; append from b; quit; %mktppro(ibd=b, print=f p) %choiceff(data=chdes, model=class(x1-x16), nsets=80, nalts=2, beta=zero, init=chdes, initvars=x1-x16) %let lev = 4; /* levels */ %let attr = 16; /* total attributes */ %let vary = 4; /* number of attributes that vary */ %let rep = 2; /* number of times each attribute must appear */ %let seed = 17; /* random number seed */ %let b = %sysevalf((&attr * &rep) / &vary); %let sets = %eval(&b * &vary); data _null_; if &b ne floor(&b) then do; put "ERROR: b = attr * rep / vary = &b must be an integer."; put 'ERROR: Try changing rep or attr.'; end; put "NOTE: attr=&attr, rep=&rep, vary=&vary, sets=&sets, b=&b.."; run; %macro con; _d = &rep # i(&m); _f = ((1:&m) @ j(&m, 1, 1) > j(1, &m, 1) @ (1:&m)`) + _d; _p = (_f = &rep) + 10 # (_f = 1); %mend; %macro res; bad = 1000 # abs(sum(x = 2) - &vary); f = j(&m, &m, 0); do ii = 1 to &n; if ii = i then l = loc(x = 2); else l = loc(xmat[ii,] = 2); if ncol(l) then f[l, l] = f[l, l] + 1; end; bad = bad + sum((abs(f - _f) >< abs(f - _d)) # _p); %mend; %mktex(2 ** &attr, n=&b, tabiter=0, optiter=0, restrictions=res, resmac=con, reslist=%str(_f, _p, _d), order=random, options=resrep nofinal, exchange=2, seed=&seed, maxdesigns=1, out=ibd, ridge=0.01) %mktex(&lev &vary &lev ** %eval(&vary - 1), n=&lev * &vary) data design; set design; drop x2; run; %mktppro(x=ibd) %choiceff(data=chdes, model=class(x1-x&attr), nsets=&sets, nalts=&lev, beta=zero, init=chdes, initvars=x1-x&attr) ******************* Begin MktRoll Macro Example Code ******************; options ls=80 ps=60 nonumber nodate; title; %mktkey(5 1) data key; input (Brand Price) ($); datalines; A x1 B x2 C x3 D x4 E x5 ; %mktex(3 ** 5, n=12) %mktroll(design=randomized, key=key, out=sasuser.design, alt=brand) %mktex(2 ** 12, n=16, seed=109) data key; input (Brand Price Size Color Shape) ($); datalines; A x1 x2 x3 x4 B x5 x6 x7 x8 C x9 x10 x11 x12 None . . . . ; %mktroll(key=key, design=randomized, out=sasuser.design, alt=brand) %mktex(2 ** 14, n=16, seed=114) data key; input (Brand Price Size Color Shape Pattern) ($); datalines; A x1 x2 x3 x4 x13 B x5 x6 x7 x8 . C x9 x10 x11 x12 x14 None . . . . . ; %mktroll(key=key, design=randomized, out=sasuser.design, alt=brand) %mktroll(key=key, design=randomized, out=sasuser.design, alt=brand, keep=x1 x5 x9) ******************* Begin MktRuns Macro Example Code ******************; options ls=80 ps=60 nonumber nodate; title; %mktruns( 2 2 2 3 3 3 3 ) %mktruns( 2 ** 3 3 ** 4 ) proc print label data=nums split='-'; id n; run; %mktruns( 2 2 3 3 4 4 5 5 ) %mktruns(2 2 3 3 4 4 5 5, max=5000) %mktruns( 2 2 2 3 3 3 3, interact=1*2, options=source ) ****************** Begin PhChoice Macro Example Code ******************; options ls=80 ps=60 nonumber nodate; title; %phchoice(on) %phchoice(off) proc template; source stat.phreg; run; proc template; edit stat.phreg.ParameterEstimates; column Label DF Estimate StdErr ChiSq ProbChiSq; header h1; define h1; text "Multinomial Logit Parameter Estimates"; space = 1; spill_margin; end; define Label; header = " " style = RowHeader; end; end; edit Stat.Phreg.CensoredSummary; column Stratum Pattern Freq GenericStrVar Total Event Censored; header h1; define h1; text "Summary of Subjects, Sets, " "and Chosen and Unchosen Alternatives"; space = 1; spill_margin; first_panel; end; define Freq; header=";Number of;Choices" format=6.0; end; define Total; header = ";Number of;Alternatives"; format_ndec = ndec; format_width = 8; end; define Event; header = ";Chosen;Alternatives"; format_ndec = ndec; format_width = 8; end; define Censored; header = "Not Chosen"; format_ndec = ndec; format_width = 8; end; end; run; * Delete edited templates, restore original templates; proc template; delete Stat.Phreg.ParameterEstimates; delete Stat.Phreg.CensoredSummary; run; %phchoice(on, Variable DF Estimate StdErr ChiSq ProbChiSq Label) %phchoice(on)