<?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: Repost: Loop over a particular combination in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Repost-Loop-over-a-particular-combination/m-p/341569#M10173</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for making you confused. The content original post is gone with the example probability table.I just updated with my post so that probability can be seen.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i means Row #, we start from Row # = 0, which means i starts at 0, and keep increasing to some threshold.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;By the way, as you mentioned,&amp;nbsp;&lt;SPAN&gt;P(Row &amp;lt; 0) = (1- P(Row &amp;gt;= 0)) always holds.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And 'Count' is a typo, please regard it as row #, and I changed it as well.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2017 13:31:23 GMT</pubDate>
    <dc:creator>Crubal</dc:creator>
    <dc:date>2017-03-16T13:31:23Z</dc:date>
    <item>
      <title>Repost: Loop over a particular combination</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Repost-Loop-over-a-particular-combination/m-p/341341#M10149</link>
      <description>&lt;P&gt;The table below lists each possibility for each variable 'A', 'B' and 'C', and the probability of that combination occurring. I already know all the probabilities.&lt;/P&gt;&lt;P&gt;Row&amp;nbsp;# | A | B | C | Probability&lt;BR /&gt;============================================================&lt;BR /&gt;0 | ... | ... | ... | P0&lt;BR /&gt;------------------------------------------------------------&lt;BR /&gt;1 | ... | ... | ... | P1&lt;BR /&gt;------------------------------------------------------------&lt;BR /&gt;. | ... | . | . | .&lt;BR /&gt;------------------------------------------------------------&lt;BR /&gt;. | ... | . | . | .&lt;BR /&gt;------------------------------------------------------------&lt;BR /&gt;10 | ... | ... | ... | P10&lt;BR /&gt;------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;I would like to write an iteration within a combination of variables 'A', 'B' and 'C', start from Row = 0, keep increasing&lt;BR /&gt;for Row # = i. If P(Row &amp;gt;= i) * 300 - P(Row &amp;lt; i) * 600 &amp;gt; 0 do i = i+1; until P(Row &amp;gt;= i) * 300 - P(Row &amp;lt; i) * 600 &amp;lt;= 0 or i =10.&lt;/P&gt;&lt;P&gt;It will stop and output i for a combination of 'A', 'B' and 'C'. And i is what I need for a combination of (A / B / C). Which is regarded as 'Threshold' in my problem.&lt;BR /&gt;&lt;BR /&gt;How could I write this kind of code since there are many combinations of variables 'A', 'B' and 'C'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Row&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;# | A | B | C | Probability&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;============================================================&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0 | ... | ... | ... |&amp;nbsp;0.05&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;------------------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1 | ... | ... | ... |&amp;nbsp;0.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;------------------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2&amp;nbsp;| ... | ... | ... | 0.15&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;------------------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3&amp;nbsp;| ... | ... | ... | 0.2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4&amp;nbsp;| ... | ... | ... | 0.2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;...................................&lt;BR /&gt;&lt;SPAN&gt;10 | ... | ... | ... |&amp;nbsp;0.03&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When i = 0, P(Row &amp;gt;= 0) * 300 - P(Row &amp;lt; 0) * 600 = 1* 300 - 0* 600 = 300 &amp;gt; 0 Hence, i = 0+1 = 1&lt;/P&gt;&lt;P&gt;When i = 1, P(Row &amp;gt;= 1) * 300 - P(Row &amp;lt; 1) * 600 = 0.95* 300 - 0.05* 600 = 255 &amp;gt; 0 i = 1+1 = 2&lt;/P&gt;&lt;P&gt;When i = 2, P(Row &amp;gt;= 2) * 300 - P(Row &amp;lt; 2) * 600 = 0.85* 300 - 0.15* 600 = 165 &amp;gt; 0 i = 2+1 = 3&lt;/P&gt;&lt;P&gt;When i = 3, P(Row &amp;gt;= 3) * 300 - P(Row &amp;lt; 3) * 600 = 0.70* 300 - 0.30* 600 = 30 &amp;gt; 0 i = 3+1 = 4&lt;/P&gt;&lt;P&gt;When i = 4, P(Row &amp;gt;= 4) * 300 - P(Row &amp;lt; 4) * 600 = 0.50* 300 - 0.50* 600 = -150 &amp;lt; 0&lt;/P&gt;&lt;P&gt;we stop and output i =4 for this combination of 'A', 'B' and 'C'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And,&amp;nbsp;&lt;SPAN&gt;P(Row &amp;gt;= i) = 1-&amp;nbsp;P(Row &amp;lt;&amp;nbsp;i)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 13:25:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Repost-Loop-over-a-particular-combination/m-p/341341#M10149</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-03-16T13:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: Repost: Loop over a particular combination</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Repost-Loop-over-a-particular-combination/m-p/341361#M10150</link>
      <description>&lt;P&gt;It really would help to post the data values. Use a datastep generated from your data. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you say this for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When i = 3, P(Row &amp;gt;= 3) * 300 - P(Row &amp;lt; 3) * 600 = 0.70* 300 - 0.30* 600 = 30 &amp;gt; 0 i = 3+1 = 4&lt;/P&gt;
&lt;P&gt;1) where does i come from at the begining? You don't mention a variable i in the description. Are you perhaps meaning two different things for i?&lt;/P&gt;
&lt;P&gt;2) What does P(Row&amp;gt;=3) mean? Is that supposed to be a specific probability value or the sum/product/difference/other calculation involving all of the probabilites for row 3 through 10? If so provide the individual values&amp;nbsp; and how they are combined to get (I assume) a value of .70.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3) why does this: When i = 2, P(Count &amp;gt;= 2) * 300 - P(Row &amp;lt; 2) * 600 = 0.85* 300 - 0.15* 600 = 165 &amp;gt; 0 i = 2+1 = 3 use &lt;STRONG&gt;count?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see a relation, I think, that &amp;nbsp;P(Row &amp;lt; 0) = (1- P(Row &amp;gt;= 0)). Does that relationship hold.&lt;/P&gt;
&lt;P&gt;I am not sure what the actual values for the probability are an how they relate as there is not any example.&amp;nbsp;example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If all of these P(Row &amp;gt;= 0)&amp;nbsp; actually mean the value of the Probability variable that is being hidden behind P0 then your formula reduces to 900*Probability - 600&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2017 22:50:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Repost-Loop-over-a-particular-combination/m-p/341361#M10150</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-15T22:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Repost: Loop over a particular combination</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Repost-Loop-over-a-particular-combination/m-p/341569#M10173</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for making you confused. The content original post is gone with the example probability table.I just updated with my post so that probability can be seen.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i means Row #, we start from Row # = 0, which means i starts at 0, and keep increasing to some threshold.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;By the way, as you mentioned,&amp;nbsp;&lt;SPAN&gt;P(Row &amp;lt; 0) = (1- P(Row &amp;gt;= 0)) always holds.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And 'Count' is a typo, please regard it as row #, and I changed it as well.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 13:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Repost-Loop-over-a-particular-combination/m-p/341569#M10173</guid>
      <dc:creator>Crubal</dc:creator>
      <dc:date>2017-03-16T13:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Repost: Loop over a particular combination</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Repost-Loop-over-a-particular-combination/m-p/341617#M10175</link>
      <description>&lt;P&gt;&amp;nbsp;P(Row &amp;gt;= 0) apparently means P0 + P1 + P2 + .. + P10.&lt;/P&gt;
&lt;P&gt;As such I think&amp;nbsp;this really needs to go to Proc IML as you are doing matrix manipulation. To do this&amp;nbsp;out side of Proc IML&amp;nbsp;I think is going to require a transpose,&amp;nbsp;several arrays and likely another transpose to get into a useable output format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you really should show enought data for a least&amp;nbsp;one use case &lt;STRONG&gt;in the form of a datastep, &lt;/STRONG&gt;the desired result in the form of a datastep as&amp;nbsp;well.&lt;/P&gt;
&lt;P&gt;I'm not going to make a fake data set to try to&amp;nbsp;write code against. You have the starting data set&amp;nbsp;and it&amp;nbsp;is very easy to transform a existing data set to datastep code.&amp;nbsp;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 15:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Repost-Loop-over-a-particular-combination/m-p/341617#M10175</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-16T15:06:15Z</dc:date>
    </item>
  </channel>
</rss>

