<?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 How do I Generate Random data with seed and restriction? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Generate-Random-data-with-seed-and-restriction/m-p/282726#M57495</link>
    <description>&lt;P&gt;So I am creating a scoring Macro for a questionnaire while I wait for my data to arrive.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create a dataset to test out the scoring macro that I have created.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, the dataset would be ID &amp;nbsp;(1,2,3,4) and Var1-var30, where Var1-30 have randomly generated whole number values between 1 and 6. Also I would like to have a seed to start so I can replicate the same dataset again. &amp;nbsp;I need maybe 10 records at most.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did some quick googling and can't seem to figure this out. The rand function&amp;nbsp;I found seem to come up with numbers with decimal values (which is not what I want, I want whole numbers 1,2,3,4,5 or 6). &amp;nbsp;I think this should be a basic task but I can't seem to figure it out &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; So I am hoping someone can help me&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jul 2016 16:16:28 GMT</pubDate>
    <dc:creator>Tpham</dc:creator>
    <dc:date>2016-07-07T16:16:28Z</dc:date>
    <item>
      <title>How do I Generate Random data with seed and restriction?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Generate-Random-data-with-seed-and-restriction/m-p/282726#M57495</link>
      <description>&lt;P&gt;So I am creating a scoring Macro for a questionnaire while I wait for my data to arrive.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create a dataset to test out the scoring macro that I have created.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, the dataset would be ID &amp;nbsp;(1,2,3,4) and Var1-var30, where Var1-30 have randomly generated whole number values between 1 and 6. Also I would like to have a seed to start so I can replicate the same dataset again. &amp;nbsp;I need maybe 10 records at most.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did some quick googling and can't seem to figure this out. The rand function&amp;nbsp;I found seem to come up with numbers with decimal values (which is not what I want, I want whole numbers 1,2,3,4,5 or 6). &amp;nbsp;I think this should be a basic task but I can't seem to figure it out &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; So I am hoping someone can help me&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 16:16:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-Generate-Random-data-with-seed-and-restriction/m-p/282726#M57495</guid>
      <dc:creator>Tpham</dc:creator>
      <dc:date>2016-07-07T16:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Generate Random data with seed and restriction?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Generate-Random-data-with-seed-and-restriction/m-p/282728#M57496</link>
      <description>&lt;P&gt;See if this gives you a start.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data want;
   array v var1-var30;
   call streaminit (123); /* this makes the random results reproducable*/
   do id=1 to 10;
      do i=1 to dim(v);
         /* the decimal values refer to the proportion of responses that should have
            the order value. ('table', .4, .3, .2, .1) would have 40% with value 1, 
            30% with 2, 20% with 3 and 10% with 1.. The values should total to 1.
            adjust as desired
            The following line says each of the varaibles with have the same overall
            distribution but the values per individual record will vary.
            If you want to have different distributions than you could have 
            single line per var and skip the i loop for array, OR have multiple 
            arrays each group with a similar distribution 
         */
         v[i]= rand('table', .25, .15, .18, .12, .2, .1); 
         
      end;
      output;
   end;
   drop i;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Jul 2016 16:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-Generate-Random-data-with-seed-and-restriction/m-p/282728#M57496</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-07T16:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I Generate Random data with seed and restriction?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-Generate-Random-data-with-seed-and-restriction/m-p/282734#M57498</link>
      <description>&lt;P&gt;Low seeds generate approximately random numbers, but that's probably all you will need for test data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;array var {30};&lt;/P&gt;
&lt;P&gt;do obsno=1 to 10;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; id = ceil(ranuni(12345) * 4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; do seed=1 to 30;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var{seed} = ceil(ranuni(seed) * 6);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 16:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-Generate-Random-data-with-seed-and-restriction/m-p/282734#M57498</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-07-07T16:45:33Z</dc:date>
    </item>
  </channel>
</rss>

