<?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: Random number store in other table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Random-number-store-in-other-table/m-p/778399#M247764</link>
    <description>&lt;P&gt;So you want to create a random number. Do you have any rules for how to make such?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS has several functions that create random numbers and one, RAND that will create random numbers from many different distributions.&lt;/P&gt;
&lt;P&gt;Example of just a few:&lt;/P&gt;
&lt;PRE&gt;data example;
   do i=1 to 10;
      rn = rand('normal',0,1);
      rb = rand('binomial', .5,10);
      rbeta = rand('beta',4,12);
      rchi  = rand('chisquare',17);
      output;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;You would call one of these, or other functions, to create your random number in a data step.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Nov 2021 01:50:58 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-11-04T01:50:58Z</dc:date>
    <item>
      <title>Random number store in other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-number-store-in-other-table/m-p/778390#M247761</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one dataset as below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Account_id Account_name Credit_balance Debit_Balance&lt;/P&gt;&lt;P&gt;1 Ajay 100 200&lt;/P&gt;&lt;P&gt;2 Vijay 300 400&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I need something like this in the same datastep&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data changed;&lt;/P&gt;&lt;P&gt;Set Input;&lt;/P&gt;&lt;P&gt;Credit_balance_changed= ranuni("uniform") *credit_balance;&lt;/P&gt;&lt;P&gt;* Here this value of Credit_balance and its randomly generated&lt;/P&gt;&lt;P&gt;variable I need in the same datastep*&lt;/P&gt;&lt;P&gt;Something like below&amp;nbsp;&lt;/P&gt;&lt;P&gt;Call execute (' proc sql; insert into new_table (select Credit_balance,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Credit_balance_changed)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But somehow I am not able to get the correct results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is really appreciated&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 00:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-number-store-in-other-table/m-p/778390#M247761</guid>
      <dc:creator>Swapnil_21</dc:creator>
      <dc:date>2021-11-04T00:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: Random number store in other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-number-store-in-other-table/m-p/778392#M247762</link>
      <description>&lt;P&gt;Is the value from the other data set supposed to brought into data set Changed?&lt;/P&gt;
&lt;P&gt;Is there some rule for which value gets brought in? Such as matching on the Account_id or Account_name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Call execute stacks code that executes after the data step that uses it. So there isn't any way you are going to get results into the data step creating changed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It probably would be a good idea to actually show what that "other table" that you haven't even bothered to name contains.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 01:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-number-store-in-other-table/m-p/778392#M247762</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-04T01:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: Random number store in other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-number-store-in-other-table/m-p/778393#M247763</link>
      <description>E. G.&lt;BR /&gt;Input&lt;BR /&gt;Account_id Account_name Credit_balance Debit_Balance&lt;BR /&gt;&lt;BR /&gt;1 Ajay 100 200&lt;BR /&gt;&lt;BR /&gt;2 Vijay 300 400&lt;BR /&gt;&lt;BR /&gt;The other output table which I want is something like this. There is no structure as such. I just need to save the original value and its randomly changed value. So table would be something like below&lt;BR /&gt;&lt;BR /&gt;Account_id Credit_balance Credit_balance_changed Debit_Balance Debit_balance_changed&lt;BR /&gt;&lt;BR /&gt;1 100 312 200 516&lt;BR /&gt;&lt;BR /&gt;2 300 678 400 794&lt;BR /&gt;&lt;BR /&gt;So basically I need to store original value and its changed value somewhere so that it can be referred later</description>
      <pubDate>Thu, 04 Nov 2021 01:17:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-number-store-in-other-table/m-p/778393#M247763</guid>
      <dc:creator>Swapnil_21</dc:creator>
      <dc:date>2021-11-04T01:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Random number store in other table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Random-number-store-in-other-table/m-p/778399#M247764</link>
      <description>&lt;P&gt;So you want to create a random number. Do you have any rules for how to make such?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS has several functions that create random numbers and one, RAND that will create random numbers from many different distributions.&lt;/P&gt;
&lt;P&gt;Example of just a few:&lt;/P&gt;
&lt;PRE&gt;data example;
   do i=1 to 10;
      rn = rand('normal',0,1);
      rb = rand('binomial', .5,10);
      rbeta = rand('beta',4,12);
      rchi  = rand('chisquare',17);
      output;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;You would call one of these, or other functions, to create your random number in a data step.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 01:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Random-number-store-in-other-table/m-p/778399#M247764</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-04T01:50:58Z</dc:date>
    </item>
  </channel>
</rss>

