<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: %ChoiceEff Restrictions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311843#M312917</link>
    <description>&lt;P&gt;I've never used these macros, but I asked a colleague who has experience with them. &amp;nbsp;He suggestst that you look in the doc for the examples that define "macro res;" &amp;nbsp;(Open the PDF, then search for that string without the quotes.) &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on that statement, I am going to guess that you should try the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro res;&lt;/P&gt;
&lt;P&gt;bad=(x[1,2] = 2 &amp;amp; x[1,1] = 1) + (x[2,2] = 2 &amp;amp; x[2,1] = 1);&lt;/P&gt;
&lt;P&gt;%mend;​&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2016 20:36:41 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2016-11-15T20:36:41Z</dc:date>
    <item>
      <title>%ChoiceEff Restrictions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311819#M312916</link>
      <description>&lt;P&gt;I'm trying to design a discrete choice experiment survey using the code from Kuhfeld's Marketing Research Methods with SAS 9. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.sas.com/techsup/technote/mr2010.pdf" target="_blank"&gt;https://support.sas.com/techsup/technote/mr2010.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;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;&lt;BR /&gt;bad=(quality = safe &amp;amp; price = 500)&lt;BR /&gt;%mend;&lt;BR /&gt;
%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;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to implement&amp;nbsp;restrictions on the choice sets, namely that the price does not equal 500 when the quality is safe. &amp;nbsp;How can I implement this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2016 18:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311819#M312916</guid>
      <dc:creator>mdk31</dc:creator>
      <dc:date>2016-11-15T18:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: %ChoiceEff Restrictions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311843#M312917</link>
      <description>&lt;P&gt;I've never used these macros, but I asked a colleague who has experience with them. &amp;nbsp;He suggestst that you look in the doc for the examples that define "macro res;" &amp;nbsp;(Open the PDF, then search for that string without the quotes.) &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on that statement, I am going to guess that you should try the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro res;&lt;/P&gt;
&lt;P&gt;bad=(x[1,2] = 2 &amp;amp; x[1,1] = 1) + (x[2,2] = 2 &amp;amp; x[2,1] = 1);&lt;/P&gt;
&lt;P&gt;%mend;​&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2016 20:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311843#M312917</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-11-15T20:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: %ChoiceEff Restrictions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311846#M312918</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That code didn't work for me, but digging deeper in the book, it seems that this has solved the problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro res;
if x[1,1] = 1 &amp;amp; x[1,2] = 2 then bad = 1;
if x[2,1] = 1 &amp;amp; x[2,2] = 2 then bad = bad + 1;
%mend;&lt;/PRE&gt;&lt;P&gt;This means that safe&amp;nbsp;never shows up with 500. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2016 20:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311846#M312918</guid>
      <dc:creator>mdk31</dc:creator>
      <dc:date>2016-11-15T20:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: %ChoiceEff Restrictions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311986#M312919</link>
      <description>&lt;P&gt;Actually, the code that you provided for the restrictions macro generates precisely the same values of bad as the code that I provided Rick. &amp;nbsp;Why did it not work for you?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2016 14:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311986#M312919</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2016-11-16T14:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: %ChoiceEff Restrictions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311990#M312920</link>
      <description>&lt;P&gt;When your restrictions are more complicated, you might want to write them in terms of the actual levels. &amp;nbsp;Here is an example of how you could do that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro res;
price   = {500 1500 2500 3500};
quality = {'raw' 'safe'};
bad = (quality[x[1,2]] = 'safe' &amp;amp; price[x[1,1]] = 500) + 
      (quality[x[2,2]] = 'safe' &amp;amp; price[x[2,1]] = 500);
%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2016 14:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/311990#M312920</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2016-11-16T14:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: %ChoiceEff Restrictions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/312094#M312921</link>
      <description>&lt;P&gt;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. &amp;nbsp;Not sure what happened the first time. &amp;nbsp;Thanks to both for your responses!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2016 19:53:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ChoiceEff-Restrictions/m-p/312094#M312921</guid>
      <dc:creator>mdk31</dc:creator>
      <dc:date>2016-11-16T19:53:06Z</dc:date>
    </item>
  </channel>
</rss>

