Hi all, I've designed an experiment using SAS macros and now I have collected a small pre-test sample to analyse the results and check if something is wrong before collecting all my data (N=1000). The design should be correct but now I'm trying to figure out how to merge/analyse the data. I describe step by step what I've done so far, it is rather long and perhaps tedious for the experts, but my belief is that looking at the whole process could be very helpful for those (like me) who have just started learning SAS applied to discrete choice modelling. The experiment consists of a series of binary choices in order to indirectly determine participants' willingness to pay for specific features of an online service. The proposed choices are between two general options A vs B. I have 14 features, of which 13 are binary (i.e., 1=feature shown, 0=feature not shown) and 1 feature has 8 levels (i.e., price, 1-2-3-4-5-6-7-8 dollars). So, my design is asymmetric, fractional factorial, and uses blocks. The design is created as follows: %mktruns (2 ** 13 8) /* tells me that a design size of 64 is a 100% efficient design*/
%mktex(2**13 8, n=64, seed=205) /* gives me an efficient solution (i.e., 100) */
*/ After this I label variables and create the two options: */
proc format;
value Status_update 1 = 1 2 = 0;
value Notes 1 = 1 2 = 0;
value Comments 1 = 1 2 = 0;
value Wall_posts 1 = 1 2 = 0;
value Private_messages 1 = 1 2 = 0;
value Chats 1 = 1 2 = 0;
value Groups 1 = 1 2 = 0;
value Newsfeed 1 = 1 2 = 0;
value Like 1 = 1 2 = 0;
value Photos_videos 1 = 1 2 = 0;
value Events 1 = 1 2 = 0;
value Gaming 1 = 1 2 = 0;
value Fan_pages 1 = 1 2 = 0;
value Price 1 = $0 2 = $1 3 = $2 4 = $3 5 = $4 6 = $5 7 = $6 8 = $7;
run;
%mktlab(data=design, /* input data set */
vars=Status_update Notes Comments Wall_posts Private_messages Chats Groups Newsfeed Like Photos_videos Events Gaming Fan_pages Price, /* new attribute names */
int=f1-f2, /* create 2 columns of 1’s in f1-f2 */
out=final, /* output design add a format statement for the attributes */
stmts=format Status_update Status_update. Notes Notes. Comments Comments. Wall_posts Wall_posts. Private_messages Private_messages. Chats Chats. Groups Groups. Newsfeed Newsfeed. Like Like. Photos_videos Photos_videos. Events Events. Gaming Gaming. Fan_pages Fan_pages. Price Price.)
proc print; run; and now I run %choiceff (thanks to Mr Kuhfeld): %choiceff(data=final, /* candidate set of alternatives */
bestout=sasuser.facebookdes, /* choice design permanently stored */
/* model with stdz orthog coding */
model=class(Status_update Notes Comments Wall_posts Private_messages Chats Groups Newsfeed Like Photos_videos Events Gaming Fan_pages Price / sta),
nsets=64, /* number of choice sets to make */
seed=205, /* random number seed */
flags=f1-f2, /* flag which alt can go where, 2 alts*/
options=relative, /* display relative D-efficiency */
beta=zero) /* assumed beta beta vector */ as there are 64 choice sets, it appeared advisable to create blocks, specifically 4 blocks with 8 choice sets each: %mktblock(data=final, /* input choice design to block */
out=sasuser.facebookdes, /* output blocked choice design stored in permanent SAS data set */
nalts=2, /* two alternatives */
nblocks=4, /* four blocks */
factors=Status_update Notes Comments Wall_posts Private_messages Chats Groups Newsfeed Like Photos_videos Events Gaming Fan_pages Price, /* 14 attributes, x1-x14 */
print=design, /* print the blocked design (only) */
seed=205) /* random number seed */ At this point a small pretest has been run, N=51, where each participant has been shown 1 random block (8 choice sets). I have read the data as follows: data chdata;
input Block Sub (c1-c8) (1.) @@;
datalines;
4 1 12212111
3 2 21121121
1 3 12212112
4 4 12211221
2 5 12211221
2 6 21121221
4 7 11111111
2 8 21121221
3 9 21121121
1 10 12212112
2 11 21221221
1 12 12211221
3 13 21122112
2 14 12211221
3 15 22111121
2 16 12221212
2 17 21121221
4 18 12211221
4 19 12212111
2 20 11111111
4 21 12212111
2 22 21121221
3 23 12211121
3 24 21122111
3 25 12211121
4 26 22221111
1 27 21111112
4 28 12211121
2 29 11221221
2 30 12121221
3 31 21121121
4 32 12211121
2 33 11211221
1 34 12211221
1 35 12212112
1 36 11112222
1 37 12211221
1 38 12211121
4 39 12212112
3 40 21121121
1 41 12212222
4 42 12212111
1 43 12211222
2 44 12211221
1 45 11111221
4 46 12212112
4 47 12212112
3 48 12211111
4 49 12212111
1 50 11212112
4 51 12212111
; At this point the idea was to merge data and design and analyse data as follows: %mktmerge(design=sasuser.facebookdes, /* input final blocked choice design */
data=chdata, /* input choice data */
out=desdata, /* output design and data */
blocks=block, /* the blocking variable is block */
nsets=8, /* 8 choice sets per subject */
nalts=2, /* 2 alternatives in each set */
setvars=c1-c8) /* the choices for each subject vars */
%phchoice(on) /* customize PHREG for a choice model */
proc phreg brief data=desdata; /* provide brief summary of strata */
ods output parameterestimates=pe; /* output parameter estimates */
class x1-x14 / ref=first; /* name all as class vars, ’1’ ref level*/
model c*c(2) = x1-x14 ; /* 1 - chosen, 2 - not chosen */
/* x1-x14 are independent vars */
strata block sub set; /* set within subject within block */
run; /* identify each choice set */ However, the proc phreg generates an error after the class command (i.e., ERROR: Variable X1 not found). MY QUESTION: I can't understand what I'm doing wrong and whether this error is related to the way I block the design or how I manage the merge. Any help would be greatly appreciated.
... View more