<?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: How to estimate a distribution based on quantiles? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-estimate-a-distribution-based-on-quantiles/m-p/274528#M58501</link>
    <description>&lt;P&gt;Check&amp;nbsp;@Rick &amp;nbsp;'s blog&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2014/06/18/distribution-from-quantiles.html" target="_blank"&gt;http://blogs.sas.com/content/iml/2014/06/18/distribution-from-quantiles.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is mine&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover expandtabs;
input Quantile Estimate ;
prob=dif(Quantile);
width=dif(Estimate);
cards;
0 80
.01 128
.05 151
.10 162
.25 184
.50 209
.75 236
.90 265
.95 284
.99 333
1 727
;
run;
proc sql;
select prob into : probs separated by ','
from have
where prob is not missing;
select Estimate into : points separated by ','
from have
where Quantile ne 1;
select width into : widths separated by ','
from have
where width is not missing;
select count(*)-1 into : count from have;
quit;
%let n=10000; /* sample size */
data want;
call streaminit(1234);
array points(&amp;amp;count) _temporary_ (&amp;amp;points);
array widths(&amp;amp;count) _temporary_ (&amp;amp;widths);
do i=1 to &amp;amp;n;
n=rand('table',&amp;amp;probs);
x=points{n}+ceil(widths{n}*rand('uniform'));
output;
end;
drop i;
run;
proc univariate data=want;
var x;
histogram x/kernel;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or An fast way is IML code , also written by me . Hope you like it .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/*
quantiles of total cholesterol from NHANES study
http://blogs.sas.com/content/iml/2014/06/18/distribution-from-quantiles.html
*/
Quantile = {0 , .01, .05, .10, .25, .50, .75, .90, .95, .99, 1};
Estimate = {80, 128, 151, 162, 184, 209, 236, 265, 284, 333, 727};
point=t(remove(Estimate,nrow(Quantile)));
width=t(remove(dif(Estimate),1));
prob=t(remove(dif(Quantile),1));
print Quantile Estimate point width prob;
/*Start to simulate uniform data*/
n=10000; /* sample size */
call randseed(123456789);
idx=t(sample(1:nrow(point),n,'replace',prob));
widths=width[idx];
points=point[idx];
eps=randfun(n,'uniform');
data=points+ceil(widths#eps); /* This is the simulate data */
/* Check the simulate data */
call histogram(data) label="Simulation" ;
call qntl(SimEst, data, Quantile);
print Quantile[F=percent6.] Estimate SimEst[F=5.];
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jun 2016 02:34:24 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-06-02T02:34:24Z</dc:date>
    <item>
      <title>How to estimate a distribution based on quantiles?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-estimate-a-distribution-based-on-quantiles/m-p/274324#M58492</link>
      <description>&lt;P&gt;I am interested in estimating a distribution given several quantiles (0.05, 0.5, 0.95) and if necessary the mean. The shape should be somehow normal. It exists a useful package called "‘rriskDistributions" in R, explained here&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://cran.r-project.org/web/packages/rriskDistributions/rriskDistributions.pdf" target="_blank"&gt;https://cran.r-project.org/web/packages/rriskDistributions/rriskDistributions.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I am looking for an analogue in SAS 9.4. Does anybody have an idea?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jun 2016 09:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-estimate-a-distribution-based-on-quantiles/m-p/274324#M58492</guid>
      <dc:creator>DaLack</dc:creator>
      <dc:date>2016-06-01T09:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to estimate a distribution based on quantiles?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-estimate-a-distribution-based-on-quantiles/m-p/274528#M58501</link>
      <description>&lt;P&gt;Check&amp;nbsp;@Rick &amp;nbsp;'s blog&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2014/06/18/distribution-from-quantiles.html" target="_blank"&gt;http://blogs.sas.com/content/iml/2014/06/18/distribution-from-quantiles.html&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is mine&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover expandtabs;
input Quantile Estimate ;
prob=dif(Quantile);
width=dif(Estimate);
cards;
0 80
.01 128
.05 151
.10 162
.25 184
.50 209
.75 236
.90 265
.95 284
.99 333
1 727
;
run;
proc sql;
select prob into : probs separated by ','
from have
where prob is not missing;
select Estimate into : points separated by ','
from have
where Quantile ne 1;
select width into : widths separated by ','
from have
where width is not missing;
select count(*)-1 into : count from have;
quit;
%let n=10000; /* sample size */
data want;
call streaminit(1234);
array points(&amp;amp;count) _temporary_ (&amp;amp;points);
array widths(&amp;amp;count) _temporary_ (&amp;amp;widths);
do i=1 to &amp;amp;n;
n=rand('table',&amp;amp;probs);
x=points{n}+ceil(widths{n}*rand('uniform'));
output;
end;
drop i;
run;
proc univariate data=want;
var x;
histogram x/kernel;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or An fast way is IML code , also written by me . Hope you like it .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
/*
quantiles of total cholesterol from NHANES study
http://blogs.sas.com/content/iml/2014/06/18/distribution-from-quantiles.html
*/
Quantile = {0 , .01, .05, .10, .25, .50, .75, .90, .95, .99, 1};
Estimate = {80, 128, 151, 162, 184, 209, 236, 265, 284, 333, 727};
point=t(remove(Estimate,nrow(Quantile)));
width=t(remove(dif(Estimate),1));
prob=t(remove(dif(Quantile),1));
print Quantile Estimate point width prob;
/*Start to simulate uniform data*/
n=10000; /* sample size */
call randseed(123456789);
idx=t(sample(1:nrow(point),n,'replace',prob));
widths=width[idx];
points=point[idx];
eps=randfun(n,'uniform');
data=points+ceil(widths#eps); /* This is the simulate data */
/* Check the simulate data */
call histogram(data) label="Simulation" ;
call qntl(SimEst, data, Quantile);
print Quantile[F=percent6.] Estimate SimEst[F=5.];
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jun 2016 02:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-estimate-a-distribution-based-on-quantiles/m-p/274528#M58501</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-06-02T02:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to estimate a distribution based on quantiles?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-estimate-a-distribution-based-on-quantiles/m-p/274853#M58524</link>
      <description>&lt;P&gt;Many thanks for your support.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jun 2016 06:01:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-estimate-a-distribution-based-on-quantiles/m-p/274853#M58524</guid>
      <dc:creator>DaLack</dc:creator>
      <dc:date>2016-06-03T06:01:15Z</dc:date>
    </item>
  </channel>
</rss>

