<?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: An iteration for particular combination in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/An-iteration-for-particular-combination/m-p/341304#M10145</link>
    <description>&lt;P&gt;It really helps to provide at least a small sample of starting&amp;nbsp;data, say one combination of A B C and the other variables and then what the desired output for that sample data would be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in view of your other post about the news vendor problem I suspect that Proc IML may be more conducive and the whole question maybe belongs in either SAS/IML Softaware and Matrix Computations or &amp;nbsp;the Mathmatical Optimization, Discrete-Event Simulation, and OR part of the forum.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Mar 2017 19:11:59 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-03-15T19:11:59Z</dc:date>
    <item>
      <title>An iteration for particular combination</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/An-iteration-for-particular-combination/m-p/341290#M10142</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Forthe following table X, for each combination of variable 'A', 'B' and 'C', there are 'Count' from 0 to 10. 'Probability' means the probability for 'Count' equals to that value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where P1 = Probability(Count = 1) &amp;nbsp;and P0 + P1 + ... + P10 = 1.&lt;/P&gt;&lt;P&gt;P0, P1, ..., P10 is known.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp;B &amp;nbsp; &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; Count &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Probability&amp;nbsp;&lt;/P&gt;&lt;P&gt;... &amp;nbsp; &amp;nbsp; ... &amp;nbsp; &amp;nbsp; ... &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P0&lt;/P&gt;&lt;P&gt;... &amp;nbsp; &amp;nbsp; ... &amp;nbsp; &amp;nbsp; ... &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;P1&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;... &amp;nbsp; &amp;nbsp; ,,, &amp;nbsp; &amp;nbsp; ,,, &amp;nbsp; &amp;nbsp; &amp;nbsp; 10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; P10&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to write an iteration within a combination of variables 'A', 'B' and 'C', start frpm Count = 0, keep increasing&amp;nbsp;&lt;/P&gt;&lt;P&gt;for count = i. If P(Count &amp;gt;= i)&amp;nbsp;* 300 -&amp;nbsp;&lt;SPAN&gt;P(Count &amp;gt;= i)&lt;/SPAN&gt; * 600 &amp;gt; 0 do i = i+1; until &lt;SPAN&gt;P(Count &amp;gt;= i)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;* &lt;/SPAN&gt;&lt;SPAN&gt;3&lt;/SPAN&gt;&lt;SPAN&gt;00 -&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;P(Count &amp;gt;= i)&lt;/SPAN&gt;&lt;SPAN&gt; * &lt;/SPAN&gt;&lt;SPAN&gt;6&lt;/SPAN&gt;&lt;SPAN&gt;00&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;lt;= 0 or i =10. It will stop and output i for a combination of 'A', 'B' and 'C'.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need is the number of i, which is regarded as a threshold number in my case (combination of A, B and C)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How could I write this kind of code since there are many combinations of variables 'A', 'B' and 'C'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As an example:&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp;B &amp;nbsp; &amp;nbsp; &amp;nbsp;C &amp;nbsp; &amp;nbsp; Count &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Probability&amp;nbsp;&lt;/P&gt;&lt;P&gt;... &amp;nbsp; &amp;nbsp; ... &amp;nbsp; &amp;nbsp; ... &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.05&lt;/P&gt;&lt;P&gt;... &amp;nbsp; &amp;nbsp; ... &amp;nbsp; &amp;nbsp; ... &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.10&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0.15&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.20&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0.20&amp;nbsp;&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp;&lt;/P&gt;&lt;P&gt;. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;. &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;... &amp;nbsp; &amp;nbsp; ,,, &amp;nbsp; &amp;nbsp; ,,, &amp;nbsp; &amp;nbsp; &amp;nbsp; 10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;When i = 0, P(Count &amp;gt;= 0) * 300 - &lt;SPAN&gt;P&lt;/SPAN&gt;&lt;SPAN&gt;(Count &amp;lt; 0) * 6&lt;/SPAN&gt;&lt;SPAN&gt;00 = 1* 300 - 0* 600 = 300 &amp;gt; 0 Hence, i = 0+1 = 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When i = 1,&amp;nbsp;P(Count &amp;gt;= 1) * 300 - P(Count &amp;lt; 1) * 600 = 0.95* 300 - 0.05* 600 = 255&amp;nbsp;&amp;gt; 0 &amp;nbsp;&amp;nbsp;i = 1+1 =&amp;nbsp;2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When i = 2,&amp;nbsp;P(Count &amp;gt;= 2) * 300 - P(Count &amp;lt; 2) * 600 = 0.85* 300 - 0.15* 600 = 165&amp;nbsp;&amp;gt; 0 &amp;nbsp;&amp;nbsp;i = 2+1 =&amp;nbsp;3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When i = 3,&amp;nbsp;P(Count &amp;gt;= 3) * 300 - P(Count &amp;lt; 3) * 600 = 0.70* 300 - 0.30* 600 = 30&amp;nbsp;&amp;gt; 0 &amp;nbsp; &amp;nbsp; i = 3+1 =&amp;nbsp;4&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;When i = 4,&amp;nbsp;P(Count &amp;gt;= 4) * 300 - P(Count &amp;lt; 4) * 600 = 0.50* 300 - 0.50* 600 = -150&amp;nbsp;&amp;lt; 0 &amp;nbsp;&amp;nbsp;we stop and output i =4 for this combination of 'A', 'B' and 'C'.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 19:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/An-iteration-for-particular-combination/m-p/341290#M10142</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-03-15T19:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: An iteration for particular combination</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/An-iteration-for-particular-combination/m-p/341304#M10145</link>
      <description>&lt;P&gt;It really helps to provide at least a small sample of starting&amp;nbsp;data, say one combination of A B C and the other variables and then what the desired output for that sample data would be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But in view of your other post about the news vendor problem I suspect that Proc IML may be more conducive and the whole question maybe belongs in either SAS/IML Softaware and Matrix Computations or &amp;nbsp;the Mathmatical Optimization, Discrete-Event Simulation, and OR part of the forum.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 19:11:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/An-iteration-for-particular-combination/m-p/341304#M10145</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-15T19:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: An iteration for particular combination</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/An-iteration-for-particular-combination/m-p/341318#M10148</link>
      <description>&lt;P&gt;Thank you! That's a good idea, I changed it and made a small example. I will look at&amp;nbsp;PROC IML as well. Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 19:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/An-iteration-for-particular-combination/m-p/341318#M10148</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-03-15T19:43:13Z</dc:date>
    </item>
  </channel>
</rss>

