<?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: calculating quantiles using proc univariate? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340658#M272694</link>
    <description>&lt;PRE&gt;
Post some more data would be better. and Post the output you want too.
I think you can try proc ranks.

CODE NOT TESTED
proc ranks data=have groups=100 out=temp;
by sample_type;
var results;
rank rank;
run;
data want;
 set temp;
 if pct=rank;
run;


&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Mar 2017 05:22:39 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-03-14T05:22:39Z</dc:date>
    <item>
      <title>calculating quantiles using proc univariate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340572#M272690</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with thousands of distirbutions different on sample typles. I want to calculate quantiles for each distribution with specific quantile levels stored in a variable. The dataset is basically like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;obs results sample_type pct&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 90&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 90&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 85&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.54&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 90&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when I use&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc univariate data =mydata;&lt;BR /&gt;&amp;nbsp; var result;&lt;BR /&gt;&amp;nbsp; output out=out_quantile mean = mean pctlpts=pct&amp;nbsp; pctlpre = p pctlname = _lb _ub ;&lt;BR /&gt;&amp;nbsp; by sample_type;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It appears that the option "pctlpts" allows numbers only. you can not assign a variable to it even it is numeric variable.&lt;/P&gt;&lt;P&gt;Is there any ways that I can make it work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 19:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340572#M272690</guid>
      <dc:creator>Smile_to_you</dc:creator>
      <dc:date>2017-03-13T19:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: calculating quantiles using proc univariate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340574#M272691</link>
      <description>&lt;P&gt;PCTLPTS is the option to tell which percentiles you are interested in for &lt;STRONG&gt;all&lt;/STRONG&gt; of the VAR variables &lt;STRONG&gt;and all values&lt;/STRONG&gt; of the BY variables. If you want the the 10th, 15th and 60th percentiles in your output you use pctlpts= 10 15 60, the PCTLPRE and PCTLNAME are the bits you use to NAME the output variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should post some example data, in the form of a datastep,&amp;nbsp;and what you want for output for a small sample. Your example data should include enough values to calculate some of the desired percentiles and include at least 2 of your sample_type values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It almost looks to me as if you may actually want to calculate a whole bunch of percentiles but only keep some of them which would require post processing the result.&lt;/P&gt;
&lt;P&gt;Do you have different PCT values for the same Sample_type?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF your PCT values were restricted to 1, 5, 10, 25, 50, 75, 90, 95 and 99 this might be practical in a single call to Proc tabulate but that procedure only does a limited set of percentiles.&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 20:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340574#M272691</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-13T20:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: calculating quantiles using proc univariate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340587#M272692</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;Thank you! Let me provide more details&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;Each sample type has a its own distribution and a specfic percentile I am interested in. For example, I want to know 90th&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;percentile for sample A and 80th percentile for Sample B. The numbers "80", "90" are stored as a variable called "pct".&amp;nbsp;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;Whan I calculate the percentiles, I want to point to that variable instead of directly typing those numbers.&amp;nbsp;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;Is it possible to do that?&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;PCTLPTS is the option to tell which percentiles you are interested in for &lt;STRONG&gt;all&lt;/STRONG&gt; of the VAR variables &lt;STRONG&gt;and all values&lt;/STRONG&gt; of the BY variables. If you want the the 10th, 15th and 60th percentiles in your output you use pctlpts= 10 15 60, the PCTLPRE and PCTLNAME are the bits you use to NAME the output variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You should post some example data, in the form of a datastep,&amp;nbsp;and what you want for output for a small sample. Your example data should include enough values to calculate some of the desired percentiles and include at least 2 of your sample_type values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It almost looks to me as if you may actually want to calculate a whole bunch of percentiles but only keep some of them which would require post processing the result.&lt;/P&gt;&lt;P&gt;Do you have different PCT values for the same Sample_type?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IF your PCT values were restricted to 1, 5, 10, 25, 50, 75, 90, 95 and 99 this might be practical in a single call to Proc tabulate but that procedure only does a limited set of percentiles.&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;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 21:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340587#M272692</guid>
      <dc:creator>Smile_to_you</dc:creator>
      <dc:date>2017-03-13T21:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: calculating quantiles using proc univariate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340588#M272693</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/78551"&gt;@Smile_to_you&lt;/a&gt; wrote:&lt;BR /&gt; Thank you! Let me provide more details Each sample type has a its own distribution and a specfic percentile I am interested in. For example, I want to know 90th percentile for sample A and 80th percentile for Sample B. The numbers "80", "90" are stored as a variable called "pct".&amp;nbsp; Whan I calculate the percentiles, I want to point to that variable instead of directly typing those numbers.&amp;nbsp; Is it possible to do that?&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Short answer is no, long answer is yes.&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;indicated you can't specify the list dynamically for different variables, but you can calculate all and then filter out the ones you don't want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2017 21:36:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340588#M272693</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-13T21:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: calculating quantiles using proc univariate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340658#M272694</link>
      <description>&lt;PRE&gt;
Post some more data would be better. and Post the output you want too.
I think you can try proc ranks.

CODE NOT TESTED
proc ranks data=have groups=100 out=temp;
by sample_type;
var results;
rank rank;
run;
data want;
 set temp;
 if pct=rank;
run;


&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Mar 2017 05:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculating-quantiles-using-proc-univariate/m-p/340658#M272694</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-14T05:22:39Z</dc:date>
    </item>
  </channel>
</rss>

