<?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: Simulate a number between 1 and -1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721639#M223698</link>
    <description>&lt;P&gt;Second example in this blog post - almost a decade old but still works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2011/08/24/how-to-generate-random-numbers-in-sas.html" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/iml/2011/08/24/how-to-generate-random-numbers-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The example below generates 10 values (do i=1 to 10) of random values, U between 0 and 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variable X, are uniform values between -1 and 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321571"&gt;@gkmzinsou&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to test a Monte Carlo simulation. Is there a way to randomly sample a number between +1 and -1 in SAS ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
call streaminit(123);       /* set random number seed */
   a = -1; b = 1;           /* example values of limits */

do i = 1 to 10;
   u = rand("Uniform");     /* u ~ U(0,1) */
   x = a + (b-a)*u; /* u ~ U(-1, 1)*/
   output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: "Newer" method via&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
call streaminit(123);

do i=1 to 10;
   randVar = rand('uniform', -1, 1);
    output;
end;

run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Feb 2021 17:37:19 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-02-24T17:37:19Z</dc:date>
    <item>
      <title>Simulate a number between 1 and -1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721634#M223696</link>
      <description>&lt;P&gt;I'm trying to test a Monte Carlo simulation. Is there a way to randomly sample a number between +1 and -1 in SAS ?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 17:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721634#M223696</guid>
      <dc:creator>gkmzinsou</dc:creator>
      <dc:date>2021-02-24T17:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate a number between 1 and -1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721637#M223697</link>
      <description>&lt;P&gt;Read this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0fpeei0opypg8n1b06qe4r040lv.htm&amp;amp;locale=en#n0e7nxjw7qig3fn18z0ey7uqc91s"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0fpeei0opypg8n1b06qe4r040lv.htm&amp;amp;locale=en#n0e7nxjw7qig3fn18z0ey7uqc91s&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 17:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721637#M223697</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-02-24T17:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate a number between 1 and -1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721639#M223698</link>
      <description>&lt;P&gt;Second example in this blog post - almost a decade old but still works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2011/08/24/how-to-generate-random-numbers-in-sas.html" target="_blank" rel="noopener"&gt;https://blogs.sas.com/content/iml/2011/08/24/how-to-generate-random-numbers-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The example below generates 10 values (do i=1 to 10) of random values, U between 0 and 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variable X, are uniform values between -1 and 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321571"&gt;@gkmzinsou&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to test a Monte Carlo simulation. Is there a way to randomly sample a number between +1 and -1 in SAS ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
call streaminit(123);       /* set random number seed */
   a = -1; b = 1;           /* example values of limits */

do i = 1 to 10;
   u = rand("Uniform");     /* u ~ U(0,1) */
   x = a + (b-a)*u; /* u ~ U(-1, 1)*/
   output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: "Newer" method via&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
call streaminit(123);

do i=1 to 10;
   randVar = rand('uniform', -1, 1);
    output;
end;

run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2021 17:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721639#M223698</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-24T17:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate a number between 1 and -1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721644#M223699</link>
      <description>&lt;P&gt;Continuous or integer?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 17:46:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721644#M223699</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-24T17:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Simulate a number between 1 and -1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721813#M223763</link>
      <description>Thanks !</description>
      <pubDate>Thu, 25 Feb 2021 11:30:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simulate-a-number-between-1-and-1/m-p/721813#M223763</guid>
      <dc:creator>gkmzinsou</dc:creator>
      <dc:date>2021-02-25T11:30:12Z</dc:date>
    </item>
  </channel>
</rss>

