<?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: Substitute arithemtic for value in table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Substitute-arithemtic-for-value-in-table/m-p/251457#M47519</link>
    <description>&lt;P&gt;Here is a way to&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;keep the sample definition separate from the data itself and&lt;/LI&gt;
&lt;LI&gt;store the data generation recipe without storing the data&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Sample definition */
data groups;
length id $8 dist $4;
input id dist n mu sigma;
datalines;
One   Norm 10 0 1.456
Two   Norm 12 0 1.567
Three Norm 14 0 1.678
;

/* Data generation recipe */
data N2015 / view=N2015;
call streaminit (8565);
set groups;
do i = 1 to n;
    x2015 = rand(dist, mu, sigma);
    output;
    end;
keep id x2015;
run;

proc print data=N2015 noobs; run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 22 Feb 2016 02:57:11 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-02-22T02:57:11Z</dc:date>
    <item>
      <title>Substitute arithemtic for value in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substitute-arithemtic-for-value-in-table/m-p/251437#M47503</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm just into the first few weeks of teaching myself SAS so am jumping around learning to do specific things and may be missing what might be basic knowledge.&amp;nbsp; I wanted to generate a random sample from a normal distribution of mean = 0 and sigma to equal a value from another process that I have now in a table.&amp;nbsp; So this works fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; N2015;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;call&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; streaminit (&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;mu = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;sigma =&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1.456&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; i = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;x2015 = rand(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"Normal"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;, mu, sigma);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;output&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;but what I want to do is instead of hard coding the 1.456 into the simga value is to call up the value from the table.&amp;nbsp; I've been about to do this within the sql procedure but I've tried a few things and am not getting the syntax correct within the data procedure.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Appologies if this is a simple questions but I've googled and searched and can't come up in answer.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2016 22:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substitute-arithemtic-for-value-in-table/m-p/251437#M47503</guid>
      <dc:creator>jo1</dc:creator>
      <dc:date>2016-02-21T22:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Substitute arithemtic for value in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substitute-arithemtic-for-value-in-table/m-p/251444#M47510</link>
      <description>&lt;P&gt;You have a few options.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. create a macro variable to hold value and then use that in your formula&lt;/P&gt;
&lt;P&gt;2. Provide table to data step to be used&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Create a macro variable */
proc sql;
select std into :sigma
from have;
quit;

data N2015;
call streaminit (1);
mu = 0;
sigma =1.456;
do i = 1 to 100;
x2015 = rand("Normal", mu, &amp;amp;sigma);
output;
end;
run;


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or assume it's table. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data N2015;
set have;
call streaminit (1);
mu = 0;
sigma =1.456;
do i = 1 to 100;
x2015 = rand("Normal", mu, sigma); /*assumes variable name is sigma*/
output;
end;
drop sigma;*drop other variables not needed;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 01:32:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substitute-arithemtic-for-value-in-table/m-p/251444#M47510</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-22T01:32:29Z</dc:date>
    </item>
    <item>
      <title>Re: Substitute arithemtic for value in table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Substitute-arithemtic-for-value-in-table/m-p/251457#M47519</link>
      <description>&lt;P&gt;Here is a way to&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;keep the sample definition separate from the data itself and&lt;/LI&gt;
&lt;LI&gt;store the data generation recipe without storing the data&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Sample definition */
data groups;
length id $8 dist $4;
input id dist n mu sigma;
datalines;
One   Norm 10 0 1.456
Two   Norm 12 0 1.567
Three Norm 14 0 1.678
;

/* Data generation recipe */
data N2015 / view=N2015;
call streaminit (8565);
set groups;
do i = 1 to n;
    x2015 = rand(dist, mu, sigma);
    output;
    end;
keep id x2015;
run;

proc print data=N2015 noobs; run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2016 02:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Substitute-arithemtic-for-value-in-table/m-p/251457#M47519</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-02-22T02:57:11Z</dc:date>
    </item>
  </channel>
</rss>

