<?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: calculate the values as per the given statement by changing a given value in Mathematical Optimization, Discrete-Event Simulation, and OR</title>
    <link>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794925#M3625</link>
    <description>proc optmodel, a new proc step for me, thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;, sas/or never be used in the pharmaceutical industry</description>
    <pubDate>Tue, 08 Feb 2022 07:15:53 GMT</pubDate>
    <dc:creator>blueskyxyz</dc:creator>
    <dc:date>2022-02-08T07:15:53Z</dc:date>
    <item>
      <title>calculate the values as per the given statement by changing a given value</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794412#M3616</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have 3 inputs, one data "Have" and two values in macro variable "value1" and "value2". I am interested in getting the data "want" as per the condition given below. Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;infile cards delimiter=",";&lt;BR /&gt;input col1 col2 col3;&lt;BR /&gt;cards;&lt;BR /&gt;1, 0.01, 100&lt;/P&gt;&lt;P&gt;2, 0.02, 90&lt;/P&gt;&lt;P&gt;3, 0.03, 80&lt;/P&gt;&lt;P&gt;4, 0.04, 70&lt;/P&gt;&lt;P&gt;5, 0.02, 60&lt;/P&gt;&lt;P&gt;6, 0.06, 50&lt;/P&gt;&lt;P&gt;7, 0.07, 40&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%let value1 =&amp;nbsp;-4.608753929;&lt;/P&gt;&lt;P&gt;%let value2 =&amp;nbsp;0.28179071;&lt;/P&gt;&lt;P&gt;now, we want to calculate col4 as value1 + (value2*col1)&lt;/P&gt;&lt;P&gt;and col5 as EXP(col4)/(1+EXP(col4)) such that&lt;/P&gt;&lt;P&gt;sumproduct(col5, col3)/sum(col3) = sumproduct(col2,col3)/sum(col3) by changing the value1 and keeping the value2 same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After optimization the "value1" should be&amp;nbsp;-4.56266639 (computed in excel) and col4, col5 should be as given in the table below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Want&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;col1&lt;/TD&gt;&lt;TD&gt;col2&lt;/TD&gt;&lt;TD&gt;col3&lt;/TD&gt;&lt;TD&gt;col4&lt;/TD&gt;&lt;TD&gt;col5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 0.01&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;TD&gt;-4.28087568&lt;/TD&gt;&lt;TD&gt;0.013641871&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 0.02&lt;/TD&gt;&lt;TD&gt;90&lt;/TD&gt;&lt;TD&gt;-3.99908497&lt;/TD&gt;&lt;TD&gt;0.018002379&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 0.03&lt;/TD&gt;&lt;TD&gt;80&lt;/TD&gt;&lt;TD&gt;-3.71729426&lt;/TD&gt;&lt;TD&gt;0.023723163&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 0.04&lt;/TD&gt;&lt;TD&gt;70&lt;/TD&gt;&lt;TD&gt;-3.43550355&lt;/TD&gt;&lt;TD&gt;0.031204128&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 0.02&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;TD&gt;-3.15371284&lt;/TD&gt;&lt;TD&gt;0.040945231&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 0.06&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;-2.87192213&lt;/TD&gt;&lt;TD&gt;0.053559135&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;&amp;nbsp; 0.07&lt;/TD&gt;&lt;TD&gt;40&lt;/TD&gt;&lt;TD&gt;-2.59013142&lt;/TD&gt;&lt;TD&gt;0.069776252&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 04 Feb 2022 07:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794412#M3616</guid>
      <dc:creator>Decay2020</dc:creator>
      <dc:date>2022-02-04T07:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the values as per the given statement by changing a given value</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794429#M3617</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let value1 = -4.608753929;
%let value2 = 0.28179071;

data want;
	retain sumproduct1 sumproduct2 sum_col3 0;
	set have;
	col4 =&amp;amp;value1. + (&amp;amp;value2.*col1);
	col5=EXP(col4)/(1+EXP(col4));
    sumproduct1=sumproduct1+col5*col3;  col5_col3=col5*col3;
    sumproduct2=sumproduct2+col2*col3;  col2_col3=col2*col3;
	sum_col3=sum_col3+col3;

	sumproduct1_=sumproduct1/sum_col3; 
	sumproduct2_=sumproduct2/sum_col3; 
	xx=col4-col5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;sumproduct(col5, col3)/sum(col3) = sumproduct(col2,col3)/sum(col3)??&lt;/P&gt;</description>
      <pubDate>Fri, 04 Feb 2022 09:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794429#M3617</guid>
      <dc:creator>blueskyxyz</dc:creator>
      <dc:date>2022-02-04T09:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the values as per the given statement by changing a given value</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794433#M3618</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table sumproduct as
    select -4.608753929 as value1
			,0.28179071 as value2
			,col1,col2,col3
			, calculated value1 + (calculated value2 *col1) as col4
			, EXP( calculated col4)/(1+EXP(calculated col4))as col5
			, sum(calculated col5*col3)/sum(col3)  as sum1, sum(col2*col3)/sum(col3)  as sum2 
    from have;
quit;
&lt;BR /&gt;/*need a do-loop for value1?*/
data sump;
	set sumproduct;
	if sum1=sum2 then value1=-4.56266639;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Feb 2022 09:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794433#M3618</guid>
      <dc:creator>blueskyxyz</dc:creator>
      <dc:date>2022-02-04T09:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the values as per the given statement by changing a given value</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794435#M3619</link>
      <description>No, we don't have value1 = -4.56266639.&lt;BR /&gt;we need to optimize the value1 starting from -4.608753929 such that sumproduct(col5, col3)/sum(col3) = 0.030612</description>
      <pubDate>Fri, 04 Feb 2022 10:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794435#M3619</guid>
      <dc:creator>Decay2020</dc:creator>
      <dc:date>2022-02-04T10:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the values as per the given statement by changing a given value</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794436#M3620</link>
      <description>i need to change the value1 from -4.608753929 such that sum product(col5 and col3)/ sum(col3) = 0.030612&lt;BR /&gt;&lt;BR /&gt;0.030612 is sumproduct(col2,col3)/sum(col3) which is computed in excel.</description>
      <pubDate>Fri, 04 Feb 2022 10:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794436#M3620</guid>
      <dc:creator>Decay2020</dc:creator>
      <dc:date>2022-02-04T10:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the values as per the given statement by changing a given value</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794577#M3622</link>
      <description>&lt;P&gt;The following does what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc optmodel;
   set OBS;
   num col1 {OBS};
   num col2 {OBS};
   num col3 {OBS};
   read data have into OBS=[_N_] col1 col2 col3;

   var value1 init &amp;amp;value1;
   num value2 = &amp;amp;value2;
   impvar col4 {i in OBS} = value1 + value2 * col1[i];
   impvar col5 {i in OBS} = EXP(col4[i]) / (1 + EXP(col4[i]));
   con SumProduct:
      sum {i in OBS} col5[i] * col3[i] = sum {i in OBS} col2[i] * col3[i];

   solve noobj;
   print value1;
   print col1 col2 col3 col4 col5;
   create data want(drop=i) from [i] col1 col2 col3 col4 col5;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: value1" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r b header" scope="col"&gt;value1&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;-4.5621&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;&lt;A name="IDX131" target="_blank"&gt;&lt;/A&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Optmodel: Print Table" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt;&lt;/COLGROUP&gt; &lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l b header" scope="col"&gt;[1]&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;col1&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;col2&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;col3&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;col4&lt;/TH&gt;
&lt;TH class="r b header" scope="col"&gt;col5&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0.01&lt;/TD&gt;
&lt;TD class="r data"&gt;100&lt;/TD&gt;
&lt;TD class="r data"&gt;-4.2803&lt;/TD&gt;
&lt;TD class="r data"&gt;0.013649&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;0.02&lt;/TD&gt;
&lt;TD class="r data"&gt;90&lt;/TD&gt;
&lt;TD class="r data"&gt;-3.9985&lt;/TD&gt;
&lt;TD class="r data"&gt;0.018012&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;0.03&lt;/TD&gt;
&lt;TD class="r data"&gt;80&lt;/TD&gt;
&lt;TD class="r data"&gt;-3.7168&lt;/TD&gt;
&lt;TD class="r data"&gt;0.023736&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;4&lt;/TH&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;0.04&lt;/TD&gt;
&lt;TD class="r data"&gt;70&lt;/TD&gt;
&lt;TD class="r data"&gt;-3.4350&lt;/TD&gt;
&lt;TD class="r data"&gt;0.031220&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;5&lt;/TH&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;TD class="r data"&gt;0.02&lt;/TD&gt;
&lt;TD class="r data"&gt;60&lt;/TD&gt;
&lt;TD class="r data"&gt;-3.1532&lt;/TD&gt;
&lt;TD class="r data"&gt;0.040966&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;6&lt;/TH&gt;
&lt;TD class="r data"&gt;6&lt;/TD&gt;
&lt;TD class="r data"&gt;0.06&lt;/TD&gt;
&lt;TD class="r data"&gt;50&lt;/TD&gt;
&lt;TD class="r data"&gt;-2.8714&lt;/TD&gt;
&lt;TD class="r data"&gt;0.053586&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="l rowheader" scope="row"&gt;7&lt;/TH&gt;
&lt;TD class="r data"&gt;7&lt;/TD&gt;
&lt;TD class="r data"&gt;0.07&lt;/TD&gt;
&lt;TD class="r data"&gt;40&lt;/TD&gt;
&lt;TD class="r data"&gt;-2.5896&lt;/TD&gt;
&lt;TD class="r data"&gt;0.069811&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 04 Feb 2022 18:35:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794577#M3622</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2022-02-04T18:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the values as per the given statement by changing a given value</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794737#M3623</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;.. this solution works perfectly. But can we update the constraint:&lt;BR /&gt;sum {i in OBS} col5[i] * col3[i] = sum {i in OBS} col2[i] * col3[i];&lt;BR /&gt;into :&lt;BR /&gt;sumproduct(col5, col3)/sum(col3) = sumproduct(col2,col3)/sum(col3) somehow?&lt;BR /&gt;as we need to divide the sumproduct with sum of col3.&lt;BR /&gt;I understand it wont impact the result as it is cancelling out, but still needed.&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Feb 2022 06:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794737#M3623</guid>
      <dc:creator>Decay2020</dc:creator>
      <dc:date>2022-02-07T06:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the values as per the given statement by changing a given value</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794819#M3624</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   con SumProduct:
      (sum {i in OBS} col5[i] * col3[i]) / (sum {i in OBS} col3[i]) 
    = (sum {i in OBS} col2[i] * col3[i]) / (sum {i in OBS} col3[i]);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Feb 2022 15:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794819#M3624</guid>
      <dc:creator>RobPratt</dc:creator>
      <dc:date>2022-02-07T15:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: calculate the values as per the given statement by changing a given value</title>
      <link>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794925#M3625</link>
      <description>proc optmodel, a new proc step for me, thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/1636"&gt;@RobPratt&lt;/a&gt;, sas/or never be used in the pharmaceutical industry</description>
      <pubDate>Tue, 08 Feb 2022 07:15:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Mathematical-Optimization/calculate-the-values-as-per-the-given-statement-by-changing-a/m-p/794925#M3625</guid>
      <dc:creator>blueskyxyz</dc:creator>
      <dc:date>2022-02-08T07:15:53Z</dc:date>
    </item>
  </channel>
</rss>

