- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to design a discrete choice experiment survey using the code from Kuhfeld's Marketing Research Methods with SAS 9.
https://support.sas.com/techsup/technote/mr2010.pdf
Here is my code:
title 'Water' %mktruns(2 2 2 4 2) %mktex(2 2 2 4 2, n=64) proc format; value provider 1 = 'public utility' 2 = 'private seller'; value measure 1 = 'tanker' 2 = 'tap'; value payment 1 = 'upfront' 2 = 'after'; value price 1 = '500' 2 = '1500' 3 = '2500' 4 = '3500'; value quality 1 = 'raw' 2 = 'safe'; run; %mktlab(data=design, vars=Provider Measure Payment Price Quality, int=f1-f2, out=final, stmts=format provider provider. measure measure. payment payment. price price. quality quality.) proc print; run; %macro res;
bad=(quality = safe & price = 500)
%mend;
%choiceff(data=final, bestout=sasuser.waterdes, model=class(provider measure payment price quality / sta) / cprefix=0 lprefix=0, nsets=32, seed=145, flags=f1-f2, restrictions=res, resvars=price quality, options=relative, beta=zero) proc print data=sasuser.waterdes; var provider -- quality; id set; by set; run; proc datasets lib=work kill nolist memtype=data; quit;
I need to implement restrictions on the choice sets, namely that the price does not equal 500 when the quality is safe. How can I implement this?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When your restrictions are more complicated, you might want to write them in terms of the actual levels. Here is an example of how you could do that.
%macro res;
price = {500 1500 2500 3500};
quality = {'raw' 'safe'};
bad = (quality[x[1,2]] = 'safe' & price[x[1,1]] = 500) +
(quality[x[2,2]] = 'safe' & price[x[2,1]] = 500);
%mend;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I've never used these macros, but I asked a colleague who has experience with them. He suggestst that you look in the doc for the examples that define "macro res;" (Open the PDF, then search for that string without the quotes.)
My friend said "Restrictions must be posed in terms of the raw values stored in a matrix x with one row per alternative and one column for each of the resvars variables."
Based on that statement, I am going to guess that you should try the following:
%macro res;
bad=(x[1,2] = 2 & x[1,1] = 1) + (x[2,2] = 2 & x[2,1] = 1);
%mend;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
That code didn't work for me, but digging deeper in the book, it seems that this has solved the problem:
%macro res; if x[1,1] = 1 & x[1,2] = 2 then bad = 1; if x[2,1] = 1 & x[2,2] = 2 then bad = bad + 1; %mend;
This means that safe never shows up with 500.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Actually, the code that you provided for the restrictions macro generates precisely the same values of bad as the code that I provided Rick. Why did it not work for you?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When your restrictions are more complicated, you might want to write them in terms of the actual levels. Here is an example of how you could do that.
%macro res;
price = {500 1500 2500 3500};
quality = {'raw' 'safe'};
bad = (quality[x[1,2]] = 'safe' & price[x[1,1]] = 500) +
(quality[x[2,2]] = 'safe' & price[x[2,1]] = 500);
%mend;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have no idea what I was putting in the first time, but this time, when I copied and pasted Rick's code, it worked. Not sure what happened the first time. Thanks to both for your responses!