<?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: monte carlo simulation with summation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/monte-carlo-simulation-with-summation/m-p/437967#M109156</link>
    <description>I do not have a SAS/IML licence and multi_base just contains a1-a5, b and w&lt;BR /&gt;that are unique for each row</description>
    <pubDate>Fri, 16 Feb 2018 13:45:55 GMT</pubDate>
    <dc:creator>jan_t_lagen</dc:creator>
    <dc:date>2018-02-16T13:45:55Z</dc:date>
    <item>
      <title>monte carlo simulation with summation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/monte-carlo-simulation-with-summation/m-p/437962#M109153</link>
      <description>&lt;P&gt;I'm trying to do a monte carlo simulation where I need to sum over the total data set as a last step and can't seem to make it work, let alone do it in a nice way.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to simulate the variable A that is made from a number of parameters and the standard normal distribution. From this I want to sum another variable w if A fulfills a specific requirement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is firstly that i can't find a way to sum these w in the same data step as the simulation of A. Since my data set is about 10 000 rows and i want to do 500 000 simulations I can't have the table growing to 500 000 * 10 000 but rather i want the final table to&amp;nbsp;have the sums of each iteration, in other words it should be&amp;nbsp;500 000&amp;nbsp;&amp;nbsp;rows&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Furthermore i'm interested in if there is a more elegant way of approaching this problem in terms of the functions used etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SAS 9.3 if its relevant.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is what i have so far, but it is not working...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data multi;&lt;BR /&gt;set multi_base;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;do iter = 1 to 2;&lt;/P&gt;&lt;P&gt;L = 0;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;A = a1*rand("Normal") +&lt;BR /&gt;a2*rand("Normal") +&lt;BR /&gt;a3*rand("Normal") +&lt;BR /&gt;a4*rand("Normal") +&lt;BR /&gt;a5*rand("Normal")&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;if A &amp;lt; b then L = L + w;&lt;/P&gt;&lt;P&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;keep iter L;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 13:32:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/monte-carlo-simulation-with-summation/m-p/437962#M109153</guid>
      <dc:creator>jan_t_lagen</dc:creator>
      <dc:date>2018-02-16T13:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: monte carlo simulation with summation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/monte-carlo-simulation-with-summation/m-p/437964#M109154</link>
      <description>&lt;P&gt;2 questions:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have a SAS/IML license?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does the data set&amp;nbsp;&lt;SPAN&gt;multi_base look like?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 13:36:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/monte-carlo-simulation-with-summation/m-p/437964#M109154</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-02-16T13:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: monte carlo simulation with summation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/monte-carlo-simulation-with-summation/m-p/437967#M109156</link>
      <description>I do not have a SAS/IML licence and multi_base just contains a1-a5, b and w&lt;BR /&gt;that are unique for each row</description>
      <pubDate>Fri, 16 Feb 2018 13:45:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/monte-carlo-simulation-with-summation/m-p/437967#M109156</guid>
      <dc:creator>jan_t_lagen</dc:creator>
      <dc:date>2018-02-16T13:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: monte carlo simulation with summation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/monte-carlo-simulation-with-summation/m-p/437991#M109161</link>
      <description>&lt;P&gt;I assume that if A &amp;gt;= b then L remains unchanged and that value of w is discarded?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Compute the conditional cumulative sum as you go along, but put&amp;nbsp;the OUTPUT statement OUTSIDE the END of the iteration loop.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 15:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/monte-carlo-simulation-with-summation/m-p/437991#M109161</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-02-16T15:00:59Z</dc:date>
    </item>
  </channel>
</rss>

