<?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: Rand function in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944357#M47164</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;once you have the location, scale, and shape parameters of the distribution from using proc univariate, is there a way to assign them to a variable name in the same way we can do it with &lt;/SPAN&gt;&lt;SPAN&gt;SAS summary statistics (e.g., max = name_for_max)? Or do I have to assign the value manually in the code (e.g., theta = 1.12345)?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;What "code" are you referring to? Show us your syntax.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_univariate_syntax09.htm" target="_self"&gt;The doc for the HISTOGRAM statement in PROC UNIVARIATE&lt;/A&gt; specifies that the syntax for the options to the parametric density keywords are of the form&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;THETA=&lt;SPAN class=" aa-argument"&gt;value-list&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=" aa-argument"&gt;SIGMA=value-list&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=" aa-argument"&gt;so the option requires specifying a list of values, not a variable name.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=" aa-argument"&gt;You could use CALL SYMPUTX in a DATA _NULL_ step to assign values in a data set to macro variables. But that trick doesn't work if you are using BY-group proccessing.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Sep 2024 08:22:36 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2024-09-18T08:22:36Z</dc:date>
    <item>
      <title>Simulate data from a distribution with a specified mean, std. dev., skew, and kurtosis</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/940397#M46947</link>
      <description>&lt;P&gt;I am using the rand function to pull simulated values from a distribution. Right now, I have it set as rand('Normal', Mu, Sigma); however, I was wondering if there was a way to specify a distribution and input its mean, std. dev., skew, and kurtosis. This way the distribution from which I simulate the data resembles its empirical distribution. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 10:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/940397#M46947</guid>
      <dc:creator>sas_user_1001</dc:creator>
      <dc:date>2024-08-23T10:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Rand function</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/940403#M46950</link>
      <description>&lt;P&gt;There are no random number functions that allow you specify mean, variance, skew and kurtosis.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could sample from the actual distribution to get something that resembles the distribution with whatever its mean, variance, skew and kurtosis are.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 21:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/940403#M46950</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-08-21T21:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Rand function</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/940431#M46955</link>
      <description>Check &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; blogs:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2024/04/15/beta-skewness-kurtosis.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2024/04/15/beta-skewness-kurtosis.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Aug 2024 02:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/940431#M46955</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-22T02:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Rand function</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/940446#M46957</link>
      <description>&lt;P&gt;Yes, there are several ways to do this. Some researchers use the moment-ratio diagram to find a distribution that is close to the (skewness, kurtosis) value, then sample from that distribution. See&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2020/01/15/moment-ratio-diagram.html" target="_blank"&gt;The moment-ratio diagram - The DO Loop (sas.com)&lt;/A&gt;&amp;nbsp; A chapter of the book &lt;EM&gt;Simulating Data with SAS&lt;/EM&gt; shows how to implement this idea by using SAS 9.4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have SAS Viya, you can &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_049/casstat/casstat_simsystem_overview.htm" target="_self"&gt;use PROC SIMSYSTEM&lt;/A&gt;, which enables you to specify the moments and will output the simulated samples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have actual data, I suggest&amp;nbsp;you model the data by using the Johnson distribution, which is conceptually the easiest flexible system. You can use PROC UNIVARIATE to perform the fit. If your data are bounded (for example, tests scores that are between 0 and 100), use the Johnson SB distribution. See&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2020/01/20/johnson-sb-distribution.html" target="_blank"&gt;The Johnson SB distribution - The DO Loop (sas.com)&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If your data are unbounded, use the Johnson SU system. See&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2020/01/27/johnson-su-distribution.html" target="_blank"&gt;The Johnson SU distribution - The DO Loop (sas.com)&lt;/A&gt; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(There is also an algorithm for deciding between the SB and SU family; see&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2020/02/12/which-johnson-distribution-su-sb.html" target="_blank"&gt;The Johnson system: Which distribution should you choose to model data? - The DO Loop (sas.com)&lt;/A&gt;)&amp;nbsp;&lt;SPAN&gt;After you have decided on a system and fit the parameters to the data, you can use the DATA step programs in those articles to produce random samples from the model.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 10:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/940446#M46957</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2024-08-22T10:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rand function</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/940550#M46964</link>
      <description>&lt;P&gt;Wonderful--thanks for the information!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 22:17:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/940550#M46964</guid>
      <dc:creator>sas_user_1001</dc:creator>
      <dc:date>2024-08-22T22:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Rand function</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944325#M47161</link>
      <description>&lt;P&gt;As a follow-up, once you have the location, scale, and shape parameters of the distribution from using proc univariate, is there a way to assign them to a variable name in the same way we can do it with SAS summary statistics (e.g., max = name_for_max)? Or do I have to assign the value manually in the code (e.g., theta = 1.12345)? Ideally, I would like the code to read: theta = name_for_theta, and call up the variable name when needed using &amp;amp;name_for_theta.&lt;/P&gt;
&lt;P&gt;Thanks for your assistance here, it has helped immensely!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 21:58:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944325#M47161</guid>
      <dc:creator>sas_user_1001</dc:creator>
      <dc:date>2024-09-17T21:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Rand function</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944357#M47164</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;once you have the location, scale, and shape parameters of the distribution from using proc univariate, is there a way to assign them to a variable name in the same way we can do it with &lt;/SPAN&gt;&lt;SPAN&gt;SAS summary statistics (e.g., max = name_for_max)? Or do I have to assign the value manually in the code (e.g., theta = 1.12345)?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;What "code" are you referring to? Show us your syntax.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_univariate_syntax09.htm" target="_self"&gt;The doc for the HISTOGRAM statement in PROC UNIVARIATE&lt;/A&gt; specifies that the syntax for the options to the parametric density keywords are of the form&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;THETA=&lt;SPAN class=" aa-argument"&gt;value-list&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=" aa-argument"&gt;SIGMA=value-list&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=" aa-argument"&gt;so the option requires specifying a list of values, not a variable name.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=" aa-argument"&gt;You could use CALL SYMPUTX in a DATA _NULL_ step to assign values in a data set to macro variables. But that trick doesn't work if you are using BY-group proccessing.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 08:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944357#M47164</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2024-09-18T08:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: Rand function</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944489#M47182</link>
      <description>&lt;P&gt;Sorry, I should have included the code instead of having you guess at what I'm doing...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc univariate data = my_data;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;var x_var;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;histogram x_var / SB(theta = &amp;amp;x_var_Min_rounddn, sigma = &amp;amp;x_var__Max_roundup, fitmethod = moments) &lt;BR /&gt;&amp;nbsp; &amp;nbsp;endpoints = (&amp;amp;x_var_Min_rounddn to &amp;amp;x_var_Max_roundup by 1);&lt;/P&gt;
&lt;P&gt;output out = temp_file_1&lt;BR /&gt;&amp;nbsp; &amp;nbsp;mean = x_var_Mean&lt;BR /&gt;&amp;nbsp; &amp;nbsp;std = x_var_Std&lt;BR /&gt;&amp;nbsp; &lt;STRONG&gt;&amp;nbsp;delta = dist_delta&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp;gamma = dist_gamma;&lt;/STRONG&gt;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set temp_file_1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;call symput('x_var_Mean', x_var_Mean);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;call symput('x_var_Std', x_var_Std);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;call symput('&lt;STRONG&gt;dist_delta&lt;/STRONG&gt;', &lt;STRONG&gt;dist_delta&lt;/STRONG&gt;);&lt;BR /&gt;&amp;nbsp; &amp;nbsp;call symput('&lt;STRONG&gt;dist_gamma&lt;/STRONG&gt;', &lt;STRONG&gt;dist_gamma&lt;/STRONG&gt;);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I was hoping to do was capture these parameter values I have bolded so I can call them up later as &amp;amp;dist_delta and &amp;amp;dist_gamma. I don't think this is possible, but you know way more than I do about SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 18:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944489#M47182</guid>
      <dc:creator>sas_user_1001</dc:creator>
      <dc:date>2024-09-18T18:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Rand function</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944496#M47183</link>
      <description>&lt;P&gt;Yes.&lt;/P&gt;
&lt;P&gt;Assuming the method of moments converges, PROC UNIVARIATE will create the ParameterEstimates table. You can write any SAS table to a data set by using the ODS OUTPUT statement. See&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html" target="_blank"&gt;ODS OUTPUT: Store any statistic created by any SAS procedure - The DO Loop&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/* Johnson SB(threshold=theta, scale=sigma, shape=gamma, shape=delta) */
data SB(keep= X);
call streaminit(1);
do i = 1 to 1000;
   x = rand("Lognormal", 0, 0.4);
   output;
end;
run; 

 /* set bins: https://blogs.sas.com/content/iml/2014/08/25/bins-for-histograms.html */
proc univariate data=SB;
   histogram X / SB(theta=0 sigma=145 fitmethod=moments);
   ods output ParameterEstimates = PE;
   output out = temp_file_1  mean = x_var_Mean std = x_var_Std;
run;


data _null_;
   set temp_file_1;
   call symput('x_var_Mean', x_var_Mean);
   call symput('x_var_Std', x_var_Std);
run;

data _null_;
   set PE;
   if symbol='Delta' then
      call symput('dist_delta', Estimate);
   if symbol='Gamma' then
      call symput('dist_gamma', Estimate);
run;

%put &amp;amp;=x_var_Mean;
%put &amp;amp;=x_var_Std;
%put &amp;amp;=dist_delta;
%put &amp;amp;=dist_gamma;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Sep 2024 19:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944496#M47183</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2024-09-18T19:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Rand function</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944503#M47184</link>
      <description>Oh, this is a wonderful solution! Thanks so much for the help!</description>
      <pubDate>Wed, 18 Sep 2024 20:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Simulate-data-from-a-distribution-with-a-specified-mean-std-dev/m-p/944503#M47184</guid>
      <dc:creator>sas_user_1001</dc:creator>
      <dc:date>2024-09-18T20:08:28Z</dc:date>
    </item>
  </channel>
</rss>

