<?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 Inefficient code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68353#M14808</link>
    <description>Hi there&lt;BR /&gt;
I've written an optimisation macro (comb) which I need to loop through 168000 times.  Unsurprisingly it's taking a while - I'm just wondering if anyone has tips for making the code more efficient.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%let att1=12;&lt;BR /&gt;
%let att2=5;&lt;BR /&gt;
%let att3=5;&lt;BR /&gt;
%let att4=4;&lt;BR /&gt;
%let att5=4;&lt;BR /&gt;
%let att6=7;&lt;BR /&gt;
%let att7=5;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data comb;&lt;BR /&gt;
do x1=1 to &amp;amp;att1;&lt;BR /&gt;
do x2=1 to &amp;amp;att2;&lt;BR /&gt;
do x3=1 to &amp;amp;att3;&lt;BR /&gt;
do x4=1 to &amp;amp;att4;&lt;BR /&gt;
do x5=1 to &amp;amp;att5;&lt;BR /&gt;
do x6=1 to &amp;amp;att6;&lt;BR /&gt;
do x7=1 to &amp;amp;att7;&lt;BR /&gt;
output; &lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data comb;&lt;BR /&gt;
set comb;&lt;BR /&gt;
num=_n_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%macro comb(num);&lt;BR /&gt;
data opt&amp;amp;num;&lt;BR /&gt;
set comb;&lt;BR /&gt;
*1st Attribute;&lt;BR /&gt;
n1=1;&lt;BR /&gt;
array a a1-a&amp;amp;att1;&lt;BR /&gt;
do over a;&lt;BR /&gt;
if x1=n1 then a=1;else a=0;&lt;BR /&gt;
n1+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*2nd Attribute;&lt;BR /&gt;
n2=1;&lt;BR /&gt;
array b b1-b&amp;amp;att2;&lt;BR /&gt;
do over b;&lt;BR /&gt;
if x2=n2 then b=1;else b=0;&lt;BR /&gt;
n2+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*3rd Attribute;&lt;BR /&gt;
n3=1;&lt;BR /&gt;
array c c1-c&amp;amp;att3;&lt;BR /&gt;
do over c;&lt;BR /&gt;
if x3=n3 then c=1;else c=0;&lt;BR /&gt;
n3+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*4th Attribute;&lt;BR /&gt;
n4=1;&lt;BR /&gt;
array d d1-d&amp;amp;att4;&lt;BR /&gt;
do over d;&lt;BR /&gt;
if x4=n4 then d=1;else d=0;&lt;BR /&gt;
n4+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*5th Attribute;&lt;BR /&gt;
n5=1;&lt;BR /&gt;
array e e1-e&amp;amp;att5;&lt;BR /&gt;
do over e;&lt;BR /&gt;
if x5=n5 then e=1;else e=0;&lt;BR /&gt;
n5+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*6th Attribute;&lt;BR /&gt;
n6=1;&lt;BR /&gt;
array f f1-f&amp;amp;att6;&lt;BR /&gt;
do over f;&lt;BR /&gt;
if x6=n6 then f=1;else f=0;&lt;BR /&gt;
n6+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*7th Attribute;&lt;BR /&gt;
n7=1;&lt;BR /&gt;
array g g1-g&amp;amp;att7;&lt;BR /&gt;
do over g;&lt;BR /&gt;
if x7=n7 then g=1;else g=0;&lt;BR /&gt;
n7+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*Add a dummy for merging;&lt;BR /&gt;
dummy=1;&lt;BR /&gt;
where num=&amp;amp;num;&lt;BR /&gt;
drop n1 n2 n3 n4 n5 n6 n7;&lt;BR /&gt;
run;&lt;BR /&gt;
*Merge onto utility data;&lt;BR /&gt;
data util_&amp;amp;num;&lt;BR /&gt;
merge util opt&amp;amp;num;&lt;BR /&gt;
by dummy;&lt;BR /&gt;
tot1=0;&lt;BR /&gt;
tot2=0;&lt;BR /&gt;
tot3=0;&lt;BR /&gt;
tot4=0;&lt;BR /&gt;
tot5=0;&lt;BR /&gt;
tot6=0;&lt;BR /&gt;
tot7=0;&lt;BR /&gt;
*1st Attribute;&lt;BR /&gt;
array a att1_lev1-att1_lev&amp;amp;att1;&lt;BR /&gt;
array b a1-a&amp;amp;att1;&lt;BR /&gt;
do over a;&lt;BR /&gt;
if a*b~=0 then tot1+a*b;&lt;BR /&gt;
end;&lt;BR /&gt;
*2nd Attribute;&lt;BR /&gt;
array c att2_lev1-att2_lev&amp;amp;att2;&lt;BR /&gt;
array d b1-b&amp;amp;att2;&lt;BR /&gt;
do over c;&lt;BR /&gt;
if c*d~=0 then tot2+c*d;&lt;BR /&gt;
end;&lt;BR /&gt;
*3rd Attribute;&lt;BR /&gt;
array e att3_lev1-att3_lev&amp;amp;att3;&lt;BR /&gt;
array f c1-c&amp;amp;att3;&lt;BR /&gt;
do over e;&lt;BR /&gt;
if e*f~=0 then tot3+e*f;&lt;BR /&gt;
end;&lt;BR /&gt;
*4th Attribute;&lt;BR /&gt;
array g att4_lev1-att4_lev&amp;amp;att4;&lt;BR /&gt;
array h d1-d&amp;amp;att4;&lt;BR /&gt;
do over g;&lt;BR /&gt;
if g*h~=0 then tot4=g*h;&lt;BR /&gt;
end;&lt;BR /&gt;
*5th Attribute;&lt;BR /&gt;
array i att5_lev1-att5_lev&amp;amp;att5;&lt;BR /&gt;
array j e1-e&amp;amp;att5;&lt;BR /&gt;
do over i;&lt;BR /&gt;
if i*j~=0 then tot5=i*j;&lt;BR /&gt;
end;&lt;BR /&gt;
*6th Attribute;&lt;BR /&gt;
array k att6_lev1-att6_lev&amp;amp;att6;&lt;BR /&gt;
array l f1-f&amp;amp;att6;&lt;BR /&gt;
do over k;&lt;BR /&gt;
if k*l~=0 then tot6=k*l;&lt;BR /&gt;
end;&lt;BR /&gt;
*7th Attribute;&lt;BR /&gt;
array m att7_lev1-att7_lev&amp;amp;att7;&lt;BR /&gt;
array n g1-g&amp;amp;att7;&lt;BR /&gt;
do over m;&lt;BR /&gt;
if m*n~=0 then tot7=m*n;&lt;BR /&gt;
end;&lt;BR /&gt;
total=sum (of tot1 tot2 tot3 tot4 tot5 tot6 tot7);&lt;BR /&gt;
if total&amp;gt;none then pick=1;else pick=0;&lt;BR /&gt;
run;&lt;BR /&gt;
proc univariate data=util_&amp;amp;num noprint;&lt;BR /&gt;
var pick;&lt;BR /&gt;
output out=pick&amp;amp;num mean=mean;&lt;BR /&gt;
*weight weight;&lt;BR /&gt;
run; 	&lt;BR /&gt;
data pick&amp;amp;num; &lt;BR /&gt;
set pick&amp;amp;num;&lt;BR /&gt;
dummy=1;&lt;BR /&gt;
run;&lt;BR /&gt;
data pick&amp;amp;num;&lt;BR /&gt;
merge pick&amp;amp;num opt&amp;amp;num;&lt;BR /&gt;
by dummy;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend comb;&lt;BR /&gt;
&lt;BR /&gt;
data util;&lt;BR /&gt;
set util;&lt;BR /&gt;
dummy=1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
dm 'log;clear;autoscroll 0';&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro dummy;&lt;BR /&gt;
%do x=1 %to 168000;&lt;BR /&gt;
%comb(&amp;amp;x);&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
%dummy;&lt;BR /&gt;
&lt;BR /&gt;
Any tips would be greatly appreciated!</description>
    <pubDate>Wed, 02 Feb 2011 15:14:15 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2011-02-02T15:14:15Z</dc:date>
    <item>
      <title>Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68353#M14808</link>
      <description>Hi there&lt;BR /&gt;
I've written an optimisation macro (comb) which I need to loop through 168000 times.  Unsurprisingly it's taking a while - I'm just wondering if anyone has tips for making the code more efficient.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%let att1=12;&lt;BR /&gt;
%let att2=5;&lt;BR /&gt;
%let att3=5;&lt;BR /&gt;
%let att4=4;&lt;BR /&gt;
%let att5=4;&lt;BR /&gt;
%let att6=7;&lt;BR /&gt;
%let att7=5;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data comb;&lt;BR /&gt;
do x1=1 to &amp;amp;att1;&lt;BR /&gt;
do x2=1 to &amp;amp;att2;&lt;BR /&gt;
do x3=1 to &amp;amp;att3;&lt;BR /&gt;
do x4=1 to &amp;amp;att4;&lt;BR /&gt;
do x5=1 to &amp;amp;att5;&lt;BR /&gt;
do x6=1 to &amp;amp;att6;&lt;BR /&gt;
do x7=1 to &amp;amp;att7;&lt;BR /&gt;
output; &lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data comb;&lt;BR /&gt;
set comb;&lt;BR /&gt;
num=_n_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%macro comb(num);&lt;BR /&gt;
data opt&amp;amp;num;&lt;BR /&gt;
set comb;&lt;BR /&gt;
*1st Attribute;&lt;BR /&gt;
n1=1;&lt;BR /&gt;
array a a1-a&amp;amp;att1;&lt;BR /&gt;
do over a;&lt;BR /&gt;
if x1=n1 then a=1;else a=0;&lt;BR /&gt;
n1+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*2nd Attribute;&lt;BR /&gt;
n2=1;&lt;BR /&gt;
array b b1-b&amp;amp;att2;&lt;BR /&gt;
do over b;&lt;BR /&gt;
if x2=n2 then b=1;else b=0;&lt;BR /&gt;
n2+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*3rd Attribute;&lt;BR /&gt;
n3=1;&lt;BR /&gt;
array c c1-c&amp;amp;att3;&lt;BR /&gt;
do over c;&lt;BR /&gt;
if x3=n3 then c=1;else c=0;&lt;BR /&gt;
n3+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*4th Attribute;&lt;BR /&gt;
n4=1;&lt;BR /&gt;
array d d1-d&amp;amp;att4;&lt;BR /&gt;
do over d;&lt;BR /&gt;
if x4=n4 then d=1;else d=0;&lt;BR /&gt;
n4+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*5th Attribute;&lt;BR /&gt;
n5=1;&lt;BR /&gt;
array e e1-e&amp;amp;att5;&lt;BR /&gt;
do over e;&lt;BR /&gt;
if x5=n5 then e=1;else e=0;&lt;BR /&gt;
n5+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*6th Attribute;&lt;BR /&gt;
n6=1;&lt;BR /&gt;
array f f1-f&amp;amp;att6;&lt;BR /&gt;
do over f;&lt;BR /&gt;
if x6=n6 then f=1;else f=0;&lt;BR /&gt;
n6+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*7th Attribute;&lt;BR /&gt;
n7=1;&lt;BR /&gt;
array g g1-g&amp;amp;att7;&lt;BR /&gt;
do over g;&lt;BR /&gt;
if x7=n7 then g=1;else g=0;&lt;BR /&gt;
n7+1;&lt;BR /&gt;
end;&lt;BR /&gt;
*Add a dummy for merging;&lt;BR /&gt;
dummy=1;&lt;BR /&gt;
where num=&amp;amp;num;&lt;BR /&gt;
drop n1 n2 n3 n4 n5 n6 n7;&lt;BR /&gt;
run;&lt;BR /&gt;
*Merge onto utility data;&lt;BR /&gt;
data util_&amp;amp;num;&lt;BR /&gt;
merge util opt&amp;amp;num;&lt;BR /&gt;
by dummy;&lt;BR /&gt;
tot1=0;&lt;BR /&gt;
tot2=0;&lt;BR /&gt;
tot3=0;&lt;BR /&gt;
tot4=0;&lt;BR /&gt;
tot5=0;&lt;BR /&gt;
tot6=0;&lt;BR /&gt;
tot7=0;&lt;BR /&gt;
*1st Attribute;&lt;BR /&gt;
array a att1_lev1-att1_lev&amp;amp;att1;&lt;BR /&gt;
array b a1-a&amp;amp;att1;&lt;BR /&gt;
do over a;&lt;BR /&gt;
if a*b~=0 then tot1+a*b;&lt;BR /&gt;
end;&lt;BR /&gt;
*2nd Attribute;&lt;BR /&gt;
array c att2_lev1-att2_lev&amp;amp;att2;&lt;BR /&gt;
array d b1-b&amp;amp;att2;&lt;BR /&gt;
do over c;&lt;BR /&gt;
if c*d~=0 then tot2+c*d;&lt;BR /&gt;
end;&lt;BR /&gt;
*3rd Attribute;&lt;BR /&gt;
array e att3_lev1-att3_lev&amp;amp;att3;&lt;BR /&gt;
array f c1-c&amp;amp;att3;&lt;BR /&gt;
do over e;&lt;BR /&gt;
if e*f~=0 then tot3+e*f;&lt;BR /&gt;
end;&lt;BR /&gt;
*4th Attribute;&lt;BR /&gt;
array g att4_lev1-att4_lev&amp;amp;att4;&lt;BR /&gt;
array h d1-d&amp;amp;att4;&lt;BR /&gt;
do over g;&lt;BR /&gt;
if g*h~=0 then tot4=g*h;&lt;BR /&gt;
end;&lt;BR /&gt;
*5th Attribute;&lt;BR /&gt;
array i att5_lev1-att5_lev&amp;amp;att5;&lt;BR /&gt;
array j e1-e&amp;amp;att5;&lt;BR /&gt;
do over i;&lt;BR /&gt;
if i*j~=0 then tot5=i*j;&lt;BR /&gt;
end;&lt;BR /&gt;
*6th Attribute;&lt;BR /&gt;
array k att6_lev1-att6_lev&amp;amp;att6;&lt;BR /&gt;
array l f1-f&amp;amp;att6;&lt;BR /&gt;
do over k;&lt;BR /&gt;
if k*l~=0 then tot6=k*l;&lt;BR /&gt;
end;&lt;BR /&gt;
*7th Attribute;&lt;BR /&gt;
array m att7_lev1-att7_lev&amp;amp;att7;&lt;BR /&gt;
array n g1-g&amp;amp;att7;&lt;BR /&gt;
do over m;&lt;BR /&gt;
if m*n~=0 then tot7=m*n;&lt;BR /&gt;
end;&lt;BR /&gt;
total=sum (of tot1 tot2 tot3 tot4 tot5 tot6 tot7);&lt;BR /&gt;
if total&amp;gt;none then pick=1;else pick=0;&lt;BR /&gt;
run;&lt;BR /&gt;
proc univariate data=util_&amp;amp;num noprint;&lt;BR /&gt;
var pick;&lt;BR /&gt;
output out=pick&amp;amp;num mean=mean;&lt;BR /&gt;
*weight weight;&lt;BR /&gt;
run; 	&lt;BR /&gt;
data pick&amp;amp;num; &lt;BR /&gt;
set pick&amp;amp;num;&lt;BR /&gt;
dummy=1;&lt;BR /&gt;
run;&lt;BR /&gt;
data pick&amp;amp;num;&lt;BR /&gt;
merge pick&amp;amp;num opt&amp;amp;num;&lt;BR /&gt;
by dummy;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend comb;&lt;BR /&gt;
&lt;BR /&gt;
data util;&lt;BR /&gt;
set util;&lt;BR /&gt;
dummy=1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
dm 'log;clear;autoscroll 0';&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%macro dummy;&lt;BR /&gt;
%do x=1 %to 168000;&lt;BR /&gt;
%comb(&amp;amp;x);&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend;&lt;BR /&gt;
&lt;BR /&gt;
%dummy;&lt;BR /&gt;
&lt;BR /&gt;
Any tips would be greatly appreciated!</description>
      <pubDate>Wed, 02 Feb 2011 15:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68353#M14808</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-02T15:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68354#M14809</link>
      <description>I think your program can be made more efficient.  But I would like to understand the big picture a bit.  Please explain the process.&lt;BR /&gt;
&lt;BR /&gt;
Your program is too macro loopy.  You are doing 5 or so steps for each observation in COMP 168000 I would not expect that to ever finish.  So "we" need to figure out how to do more work in fewer steps.  Processing all obs in COMB in each step.  &lt;BR /&gt;
&lt;BR /&gt;
It looks like the first step in the MACRO that creates 168000 data sets OPT&amp;amp;num is creating dummy variables similar to a design matrix.  If that is the case this code will do that work for all obs in one step.&lt;BR /&gt;
&lt;BR /&gt;
Let me know if this is going in the right direction and explain the overall process.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data comb;&lt;BR /&gt;
   do x1=1 to &amp;amp;att1;&lt;BR /&gt;
      do x2=1 to &amp;amp;att2;&lt;BR /&gt;
         do x3=1 to &amp;amp;att3;&lt;BR /&gt;
            do x4=1 to &amp;amp;att4;&lt;BR /&gt;
               do x5=1 to &amp;amp;att5;&lt;BR /&gt;
                  do x6=1 to &amp;amp;att6;&lt;BR /&gt;
                     do x7=1 to &amp;amp;att7;&lt;BR /&gt;
                        num + 1;&lt;BR /&gt;
                        output; &lt;BR /&gt;
                        end;&lt;BR /&gt;
                     end;&lt;BR /&gt;
                  end;&lt;BR /&gt;
               end;&lt;BR /&gt;
            end;&lt;BR /&gt;
         end;&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc glmmod data=comb noprint outdesign=opt;&lt;BR /&gt;
   class x1-x7;&lt;BR /&gt;
   model num=x1-x7 / noint;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc contents data=opt varnum;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 02 Feb 2011 17:38:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68354#M14809</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-02-02T17:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68355#M14810</link>
      <description>To start, review your code for unnecessary DATA steps, for starters the NUM assignment can be coded in the initial DATA step.&lt;BR /&gt;
&lt;BR /&gt;
And are you certain the code works, as you have posted - what is this stmt doing (several statements are missing trailing semi-colons as well):&lt;BR /&gt;
&lt;BR /&gt;
where num=#&lt;BR /&gt;
&lt;BR /&gt;
Recommend setting FULLSTIMER option and interrogate each step, either PROC or DATA type.  Isolate steps that may be consolidated into prior steps.  Investigate using SAS views, where applicable.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 02 Feb 2011 17:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68355#M14810</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-02-02T17:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68356#M14811</link>
      <description>Thanks - I will try out this code.&lt;BR /&gt;
You're right that the opt&amp;amp;num datasets are alternatives from a design matrix.  The program is designed to take conjoint utilities and calculate the overall utility of a certain set of attributes.  There are seven attributes - with number of levels defined by att1-att7.  Overall there are 168000 possible combinations of attribute levels.&lt;BR /&gt;
The util dataset contains the utilities for 2000 respondents - so what I'm doing (or trying to do!) is merge on each design - calculate if an individual would pick that configuration and then calculate an average across everyone.&lt;BR /&gt;
So the final output is an appeal score for each of the 168000 combinations. &lt;BR /&gt;
Doing it all in one step is certainly something I'll be looking into.</description>
      <pubDate>Wed, 02 Feb 2011 17:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68356#M14811</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-02T17:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68357#M14812</link>
      <description>The where num=&amp;amp;num clause is making sure I identify each specific design.  But looking at the other reply I'm wondering if instead I can do one big step on all respondents/ all designs at once. &lt;BR /&gt;
And - yes - it works fine on more manageable designs with less combinations to test out.  It's just the size of this specific problem that's killing it.</description>
      <pubDate>Wed, 02 Feb 2011 17:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68357#M14812</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-02T17:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68358#M14813</link>
      <description>Tried the code and it's definitely the way forward!  Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 02 Feb 2011 18:02:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68358#M14813</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-02T18:02:13Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68359#M14814</link>
      <description>Please show example of UTIL data or e-mail it to me at IEBUPDTE@GMAIL.COM.</description>
      <pubDate>Wed, 02 Feb 2011 18:22:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68359#M14814</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-02-02T18:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68360#M14815</link>
      <description>This is what's in the UTIL dataset&lt;BR /&gt;
&lt;BR /&gt;
respid - identifier for each respondent&lt;BR /&gt;
att1lev1-att1lev12&lt;BR /&gt;
att2lev1-att2lev5&lt;BR /&gt;
att3lev1-att3lev5&lt;BR /&gt;
att4lev1-att4lev4&lt;BR /&gt;
att5lev1-att5lev4&lt;BR /&gt;
att6lev1-att6lev7&lt;BR /&gt;
att7lev1-att7lev5&lt;BR /&gt;
none - the utility score associated with none.&lt;BR /&gt;
The attXlevY variables are real numbers - summing to 0 across each attribute. &lt;BR /&gt;
Please let me know if you need more information.</description>
      <pubDate>Thu, 03 Feb 2011 09:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68360#M14815</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-03T09:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68361#M14816</link>
      <description>Can you post a few records?</description>
      <pubDate>Thu, 03 Feb 2011 12:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68361#M14816</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-02-03T12:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68362#M14817</link>
      <description>Sure - here you go:-&lt;BR /&gt;
&lt;BR /&gt;
respid	att1_lev1	att1_lev2	att1_lev3	att1_lev4	att1_lev5	att1_lev6	att1_lev7	att1_lev8	att1_lev9	att1_lev10	att1_lev11	att1_lev12	att2_lev1	att2_lev2	att2_lev3	att2_lev4	att2_lev5	att3_lev1	att3_lev2	att3_lev3	att3_lev4	att3_lev5	att4_lev1	att4_lev2	att4_lev3	att4_lev4	att5_lev1	att5_lev2	att5_lev3	att5_lev4	att6_lev1	att6_lev2	att6_lev3	att6_lev4	att6_lev5	att6_lev6	att6_lev7	att7_lev1	att7_lev2	att7_lev3	att7_lev4	att7_lev5	none&lt;BR /&gt;
1	1.755	-0.358	-1.561	-0.114	-1.135	0.564	1.21	-1.237	-1.431	1.247	0.37	0.691	-0.828	-0.32	0.007	0.742	0.4	-2.432	0.762	0.798	0.872	-0.641	0.931	-0.348	0.805	-0.747	2.162	1.729	0.323	-4.214	1.228	0.35	-0.363	1.649	-0.314	-0.005	-2.544	1.411	0.291	0.739	-2.076	-0.365	4.765&lt;BR /&gt;
2	-0.836	-0.354	-0.428	1.501	-1.386	0.051	-0.23	0.968	0.857	-0.248	0.439	-0.333	0.328	0.172	1.37	0.152	-2.022	-2.435	-0.406	1.675	1.167	-0.558	0.837	-0.325	-0.05	0.095	0.88	1.325	1.384	-3.589	3.569	0.71	-0.034	-0.043	0.891	-1.405	-3.688	1.277	0.149	-0.539	-0.944	0.057	6.249&lt;BR /&gt;
3	-1.116	0.309	-0.456	-0.004	0.199	-0.384	-0.386	0.032	0.291	-0.252	0.961	0.805	-0.491	-0.277	0.63	0.582	-0.444	-1.911	0.244	1.013	0.653	-0.885	-0.811	0.208	0.701	0.787	6.332	1.262	-1.957	-5.637	1.2	1.034	0.586	-0.523	-0.098	-0.626	-1.571	-0.581	0.9	0.066	-1.022	0.637	7.085&lt;BR /&gt;
4	0.325	-0.934	0.627	-0.913	0.98	0.125	-1.125	0.404	-0.535	0.918	1.103	-0.975	-1.859	0.35	1.71	-0.048	-0.153	-3.26	-0.091	0.595	2.756	0.156	-0.56	0.489	-0.002	-0.082	5.518	1.427	-1.683	-5.263	0.375	0.157	0.182	-0.468	0.682	-0.243	-0.684	0.211	0.553	0.614	-1.577	0.197	5.809&lt;BR /&gt;
&lt;BR /&gt;
Not easy to see here - but should copy okay into Excel or something.&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 03 Feb 2011 13:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68362#M14817</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-03T13:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68363#M14818</link>
      <description>I think I understand most of what you are doing and have a program that only takes a few seconds to run.  It is still not the most efficient way as I think it can all be done in one data step.  But I haven't figured that out.&lt;BR /&gt;
&lt;BR /&gt;
1) create scoring coeficents for each LEVel of each ATTribute.  I used TRANSREG instead of GLMMOD because it names the new variables in a way that makes it easy to use with PROC SCORE.&lt;BR /&gt;
2) For each of the 186,000 sets of coeficients compute the TOTAL from the UTIL data. PROC SCORE.&lt;BR /&gt;
3) compare TOTAL to NONE and make a note of the ones that are larger than NUM.&lt;BR /&gt;
4) not sure what to do next.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let att1=12;&lt;BR /&gt;
%let att2=5;&lt;BR /&gt;
%let att3=5;&lt;BR /&gt;
%let att4=4;&lt;BR /&gt;
%let att5=4;&lt;BR /&gt;
%let att6=7;&lt;BR /&gt;
%let att7=5;&lt;BR /&gt;
data comb;&lt;BR /&gt;
   do att1_lev=1 to &amp;amp;att1;&lt;BR /&gt;
      do att2_lev=1 to &amp;amp;att2;&lt;BR /&gt;
         do att3_lev=1 to &amp;amp;att3;&lt;BR /&gt;
            do att4_lev=1 to &amp;amp;att4;&lt;BR /&gt;
               do att5_lev=1 to &amp;amp;att5;&lt;BR /&gt;
                  do att6_lev=1 to &amp;amp;att6;&lt;BR /&gt;
                     do att7_lev=1 to &amp;amp;att7;&lt;BR /&gt;
                        num + 1;&lt;BR /&gt;
                        length id $8;&lt;BR /&gt;
                        id = cats('s',put(num,z6.));&lt;BR /&gt;
                        output; &lt;BR /&gt;
                        end;&lt;BR /&gt;
                     end;&lt;BR /&gt;
                  end;&lt;BR /&gt;
               end;&lt;BR /&gt;
            end;&lt;BR /&gt;
         end;&lt;BR /&gt;
      end;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc transreg data=comb design;&lt;BR /&gt;
   model class(att: / zero=none);&lt;BR /&gt;
   id id;&lt;BR /&gt;
   output out=opt(drop=intercept);&lt;BR /&gt;
   run;&lt;BR /&gt;
proc contents data=opt varnum;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print data=opt(obs=10);&lt;BR /&gt;
   run; &lt;BR /&gt;
&lt;BR /&gt;
data util;&lt;BR /&gt;
   infile cards;&lt;BR /&gt;
   input &lt;BR /&gt;
      respid &lt;BR /&gt;
      att1_lev1-att1_lev12 &lt;BR /&gt;
      att2_lev1-att2_lev5 &lt;BR /&gt;
      att3_lev1-att3_lev5 &lt;BR /&gt;
      att4_lev1-att4_lev4 &lt;BR /&gt;
      att5_lev1-att5_lev4 &lt;BR /&gt;
      att6_lev1-att6_lev7 &lt;BR /&gt;
      att7_lev1-att7_lev5 &lt;BR /&gt;
      none;&lt;BR /&gt;
   cards;   &lt;BR /&gt;
1 1.755 -0.358 -1.561 -0.114 -1.135 0.564 1.21 -1.237 -1.431 1.247 0.37 0.691 &lt;BR /&gt;
-0.828 -0.32 0.007 0.742 0.4 -2.432 0.762 0.798 0.872 -0.641 0.931 -0.348 &lt;BR /&gt;
0.805 -0.747 2.162 1.729 0.323 -4.214 1.228 0.35 -0.363 1.649 -0.314 -0.005 &lt;BR /&gt;
-2.544 1.411 0.291 0.739 -2.076 -0.365 4.765&lt;BR /&gt;
2 -0.836 -0.354 -0.428 1.501 -1.386 0.051 -0.23 0.968 0.857 -0.248 0.439 &lt;BR /&gt;
-0.333 0.328 0.172 1.37 0.152 -2.022 -2.435 -0.406 1.675 1.167 -0.558 0.837 &lt;BR /&gt;
-0.325 -0.05 0.095 0.88 1.325 1.384 -3.589 3.569 0.71 -0.034 -0.043 0.891 &lt;BR /&gt;
-1.405 -3.688 1.277 0.149 -0.539 -0.944 0.057 6.249&lt;BR /&gt;
3 -1.116 0.309 -0.456 -0.004 0.199 -0.384 -0.386 0.032 0.291 -0.252 0.961 &lt;BR /&gt;
0.805 -0.491 -0.277 0.63 0.582 -0.444 -1.911 0.244 1.013 0.653 -0.885 -0.811 &lt;BR /&gt;
0.208 0.701 0.787 6.332 1.262 -1.957 -5.637 1.2 1.034 0.586 -0.523 -0.098 &lt;BR /&gt;
-0.626 -1.571 -0.581 0.9 0.066 -1.022 0.637 7.085&lt;BR /&gt;
4 0.325 -0.934 0.627 -0.913 0.98 0.125 -1.125 0.404 -0.535 0.918 1.103 -0.975 &lt;BR /&gt;
-1.859 0.35 1.71 -0.048 -0.153 -3.26 -0.091 0.595 2.756 0.156 -0.56 0.489 &lt;BR /&gt;
-0.002 -0.082 5.518 1.427 -1.683 -5.263 0.375 0.157 0.182 -0.468 0.682 &lt;BR /&gt;
-0.243 -0.684 0.211 0.553 0.614 -1.577 0.197 5.809&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
proc score data=util score=opt out=utilScr;&lt;BR /&gt;
   id respid none;&lt;BR /&gt;
   var &lt;BR /&gt;
      att1_lev1-att1_lev12 &lt;BR /&gt;
      att2_lev1-att2_lev5 &lt;BR /&gt;
      att3_lev1-att3_lev5 &lt;BR /&gt;
      att4_lev1-att4_lev4 &lt;BR /&gt;
      att5_lev1-att5_lev4 &lt;BR /&gt;
      att6_lev1-att6_lev7 &lt;BR /&gt;
      att7_lev1-att7_lev5 &lt;BR /&gt;
      ;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print data=utilscr(drop=s000011-s168000); &lt;BR /&gt;
   * this data set has LOTS of variables so be careful when printing it.;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
* create a data set of scores that are larger than NONE.;&lt;BR /&gt;
data pick;&lt;BR /&gt;
   set utilScr;&lt;BR /&gt;
   array s&lt;LI&gt; s:;&lt;BR /&gt;
   drop s:;&lt;BR /&gt;
   do pickid = 1 to dim(s);&lt;BR /&gt;
      if s[pickid] gt none then do;&lt;BR /&gt;
         total = s[pickid];&lt;BR /&gt;
         output;&lt;BR /&gt;
         end;&lt;BR /&gt;
      end;   &lt;BR /&gt;
   run;&lt;BR /&gt;
proc print data=pick(obs=100);&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]&lt;/LI&gt;</description>
      <pubDate>Thu, 03 Feb 2011 19:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68363#M14818</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-02-03T19:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: Inefficient code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68364#M14819</link>
      <description>This is exactly what I need - thanks a lot for that.&lt;BR /&gt;
All I need to do at the end is calculate how many idividuals have picked each item which is really straightforward from the PICK dataset. &lt;BR /&gt;
Genius!</description>
      <pubDate>Fri, 04 Feb 2011 11:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inefficient-code/m-p/68364#M14819</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-02-04T11:41:56Z</dc:date>
    </item>
  </channel>
</rss>

