<?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 random number generation and two DO%E2%80%A6END loops in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602186#M174298</link>
    <description>&lt;P&gt;I need to Use SAS random number generation functions `RAND()` and a `DO....END loop` to create 100 obs in variable named X then I want to use another DO loop of 500 rounds to generate a total of 500 samples, each with 100 obs. a sample is basically sampling from a standard normal distribution.&lt;/P&gt;&lt;P&gt;I tried the following code but it does not give me what I need:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    data A;
    call streaminit(123);   /* set random number seed */
    do i = 1 to 100;
    X = rand("Normal");     /* random number generator */
     output;
    end;
    
    do r = 1 to 500 ;
    if i then X = rand("Normal");
    output;
    end;
    run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any input will be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Nov 2019 19:37:32 GMT</pubDate>
    <dc:creator>mrahouma</dc:creator>
    <dc:date>2019-11-06T19:37:32Z</dc:date>
    <item>
      <title>random number generation and two DO%E2%80%A6END loops in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602186#M174298</link>
      <description>&lt;P&gt;I need to Use SAS random number generation functions `RAND()` and a `DO....END loop` to create 100 obs in variable named X then I want to use another DO loop of 500 rounds to generate a total of 500 samples, each with 100 obs. a sample is basically sampling from a standard normal distribution.&lt;/P&gt;&lt;P&gt;I tried the following code but it does not give me what I need:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    data A;
    call streaminit(123);   /* set random number seed */
    do i = 1 to 100;
    X = rand("Normal");     /* random number generator */
     output;
    end;
    
    do r = 1 to 500 ;
    if i then X = rand("Normal");
    output;
    end;
    run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any input will be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 19:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602186#M174298</guid>
      <dc:creator>mrahouma</dc:creator>
      <dc:date>2019-11-06T19:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: random number generation and two DO%E2%80%A6END loops in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602190#M174301</link>
      <description>I think you're using observations/records here in a confusing fashion. &lt;BR /&gt;How many rows and columns are you expecting in your output data set?</description>
      <pubDate>Wed, 06 Nov 2019 19:53:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602190#M174301</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-06T19:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: random number generation and two DO%E2%80%A6END loops in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602192#M174303</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288813"&gt;@mrahouma&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Do I understand you correctly that you want 50,000 records with random X where the first 100 have I=1, the next 100 have I=2, and so on till the last 100 with I=500? If so, you need to &lt;EM&gt;nest&lt;/EM&gt; the DO loops, like so: &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;                                                                                                                             
  call streaminit(123) ;                                                                                                                
  do I = 1 to 500 ;                                                                                                                     
    do _n_ = 1 to 100 ;                                                                                                                 
      X = rand ("normal") ;                                                                                                             
      output ;                                                                                                                          
    end ;                                                                                                                               
  end ;                                                                                                                                 
run ;     
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2019 19:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602192#M174303</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-11-06T19:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: random number generation and two DO%E2%80%A6END loops in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602199#M174309</link>
      <description>Thanks a lot</description>
      <pubDate>Wed, 06 Nov 2019 20:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602199#M174309</guid>
      <dc:creator>mrahouma</dc:creator>
      <dc:date>2019-11-06T20:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: random number generation and two DO%E2%80%A6END loops in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602200#M174310</link>
      <description>Thanks for your time. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt; has replied this. Appreciate your efforts.</description>
      <pubDate>Wed, 06 Nov 2019 20:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/random-number-generation-and-two-DO-E2-80-A6END-loops-in-sas/m-p/602200#M174310</guid>
      <dc:creator>mrahouma</dc:creator>
      <dc:date>2019-11-06T20:20:43Z</dc:date>
    </item>
  </channel>
</rss>

