<?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: Trouble running bootstrap off of optmodel output in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/548052#M2637</link>
    <description>&lt;P&gt;Yes, that will work, with some modifications:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Omit the BY statement, which is not directly supported in PROC OPTMODEL.&lt;/LI&gt;
&lt;LI&gt;Read from now_1 instead of work1.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;You can also simplify the code by omitting the ODS OUTPUT and PRINT statements and instead doing this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create data soln_1 from {j in 1..13} &amp;lt;col('cat_'||j)=x[j]&amp;gt;;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then omit the PROC TRANSPOSE and subsequent DATA step.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2019 21:12:46 GMT</pubDate>
    <dc:creator>RobPratt</dc:creator>
    <dc:date>2019-04-02T21:12:46Z</dc:date>
    <item>
      <title>Trouble running bootstrap off of optmodel output</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/547967#M2632</link>
      <description>&lt;P&gt;I need to loop over the attached code 5000 times. I want to pick 400 random observations from the main dataset then run the optmodel code. I want to save this output to "storage". I thought I would be able to use the sample id from the random sample output but optmodel does not allow by processing the way I want. Any ideas on how to implement this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The main dataset looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cat_1 cat_2 cat_3 ... cat_12 dwpi_hours&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5 ...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let no_obs = 400; *how many observations in bootstrap/Must be less than 468 since you only have 468 employee pins;
%Let no_runs = 5000; *how many runs of the resampling you want/this is how many solution sets you'll get/average of which will be mean time value/BIGGER IS BETTER;

data storage; /*THIS WILL STORE THE OUTPUTS FROM EACH RUN*/
INFILE DATALINES;
input cat_1 cat_2 cat_3 cat_4 cat_5 cat_6 cat_7 cat_8 cat_9 cat_10 cat_11 cat_12 cat_13;
DATALINES;
0 0 0 0 0 0 0 0 0 0 0 0 0
;
RUN;



%macro do_optmodel;
%do i=1 %to &amp;amp;no_runs;

proc surveyselect data=work.work1 NOPRINT method = urs sampsize = &amp;amp;no_obs reps=1 /*seed=12345*/ out = now_1 outhits; 
run;

proc optmodel;
by SampleID;
ods output PrintTable = exss; /*THIS PRODUCES THE SOLUTION SET OF TIME COEFFICIENTS*/
set S = 1..&amp;amp;no_obs;   /*Number of observations in the data set*/
number cat_1{S};  *Initializing variables;
number cat_2{S};
number cat_3{S};
number cat_4{S};
number cat_5{S};
number cat_6{S};
number cat_7{S};
number cat_8{S};
number cat_9{S};
number cat_10{S};
number cat_11{S};
number cat_12{S};
number dwpi_hours{S};
var x{1..13} init .5;  *initializing coefficients/Must update here if category count changes;
min f = sum{i in S}(dwpi_hours[i] - (cat_1[i]*x[1]+         /*declaring objective function*/
cat_2[i]*x[2]+
cat_3[i]*x[3]+
cat_4[i]*x[4]+
cat_5[i]*x[5]+
cat_6[i]*x[6]+
cat_7[i]*x[7]+
cat_8[i]*x[8]+
cat_9[i]*x[9]+
cat_10[i]*x[10]+
cat_11[i]*x[11]+
cat_12[i]*x[12]+
x[13]))^2;
con c1: x[2]-x[1] &amp;gt;= .25;
con c2: x[3]-x[2] &amp;gt;= .25;
con c3: x[4]-x[3] &amp;gt;= .25;
con c4: x[5]-x[4] &amp;gt;= .25;
con c5: x[6]-x[5] &amp;gt;= .25;
con c6: x[7]-x[6] &amp;gt;= .25;
con c7: x[8]-x[7] &amp;gt;= .25;
con c8: x[9]-x[8] &amp;gt;= .25;
con c9: x[10]-x[9] &amp;gt;= .25;
con c10: x[11]-x[10] &amp;gt;= .25;
con c11: x[12]-x[11] &amp;gt;= .25;

con c12: 2 &amp;lt;= x[1] &amp;lt;= 8;
con c13: 2 &amp;lt;= x[2] &amp;lt;= 10;
con c14: 2 &amp;lt;= x[3] &amp;lt;= 10;
con c15: 2 &amp;lt;= x[4] &amp;lt;= 10;
con c16: 3 &amp;lt;= x[5] &amp;lt;= 14;
con c17: 3 &amp;lt;= x[6] &amp;lt;= 14;
con c18: 3 &amp;lt;= x[7] &amp;lt;= 15;
con c19: 3 &amp;lt;= x[8] &amp;lt;= 15;
con c20: 3 &amp;lt;= x[9] &amp;lt;= 16;
con c21: 3 &amp;lt;= x[10] &amp;lt;= 16;
con c22: 3 &amp;lt;= x[11] &amp;lt;= 16;
con c23: 3 &amp;lt;= x[12] &amp;lt;= 16;
read data work.work1 into [_n_] cat_1    /*reading in rows of observations from data returned from sampling with replacement*/
cat_2
cat_3
cat_4
cat_5
cat_6
cat_7
cat_8
cat_9
cat_10
cat_11
cat_12
dwpi_hours;
solve;
print x;
quit;

/*TRANSPOSING AND SAVING SOLUTION SET OF COEFFICIENTS FOR THIS RUN */
proc transpose data=exss
out=solns_t
prefix=cat_;
var x;
run;
/* DROPPING CLUTTER VARIABLE FROM SOLUTION OUTPUT*/
data soln_1;
set solns_t(drop=_name_);
run;

/* APPENDING CURRENT SOLUTION TO GROUP OF PREVIOUS SOLUTIONS*/
proc append base=storage data=soln_1;
run;
%END;
%MEND do_optmodel;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Apr 2019 19:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/547967#M2632</guid>
      <dc:creator>Mbs270</dc:creator>
      <dc:date>2019-04-02T19:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble running bootstrap off of optmodel output</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/547996#M2634</link>
      <description>&lt;P&gt;Tried enclosing everything in a do but that did not work. All I want is something like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;do i=1 to no_runs;&lt;/P&gt;&lt;P&gt;"run all the code above";&lt;/P&gt;&lt;P&gt;"append output to storage"&lt;/P&gt;&lt;P&gt;i=i+1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 18:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/547996#M2634</guid>
      <dc:creator>Mbs270</dc:creator>
      <dc:date>2019-04-02T18:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble running bootstrap off of optmodel output</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/548007#M2635</link>
      <description>&lt;P&gt;Please see &lt;A href="http://support.sas.com/kb/42/332.html" target="_self"&gt;this SAS Usage Note&lt;/A&gt;&amp;nbsp;for an example of BY-group processing with PROC OPTMODEL.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 18:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/548007#M2635</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2019-04-02T18:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble running bootstrap off of optmodel output</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/548008#M2636</link>
      <description>&lt;P&gt;I edited the code with my current attempt. Is there anyway to make this simple macro work? It's intuitive and should work? I sandwiched the proc optmodel code between a macro call:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro do_optmodel;
%do i=1 %to &amp;amp;no_runs;

proc optmodel....

%end;
%mend do_optmodel;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Apr 2019 19:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/548008#M2636</guid>
      <dc:creator>Mbs270</dc:creator>
      <dc:date>2019-04-02T19:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble running bootstrap off of optmodel output</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/548052#M2637</link>
      <description>&lt;P&gt;Yes, that will work, with some modifications:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Omit the BY statement, which is not directly supported in PROC OPTMODEL.&lt;/LI&gt;
&lt;LI&gt;Read from now_1 instead of work1.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;You can also simplify the code by omitting the ODS OUTPUT and PRINT statements and instead doing this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create data soln_1 from {j in 1..13} &amp;lt;col('cat_'||j)=x[j]&amp;gt;;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then omit the PROC TRANSPOSE and subsequent DATA step.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 21:12:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/Trouble-running-bootstrap-off-of-optmodel-output/m-p/548052#M2637</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2019-04-02T21:12:46Z</dc:date>
    </item>
  </channel>
</rss>

