<?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: Number of Digits for UNIVARIATE PCTLPTS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705421#M216402</link>
    <description>&lt;P&gt;My previous example was incorrect—let me further simplify the problem.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do t=1 to 5;
do i=1 to 200000;
x=rannor(1);
output;
end;
end;
run;

proc univariate noprint;
var x;
output pctlpre=x pctlpts=1.001 1.002 out=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If a data set is large enough, then the 1.001th and 1.002th percentiles will differ—SAS returns not the latter but the error message. Is calculating these impossible with PROC UNIVARIATE?&lt;/P&gt;</description>
    <pubDate>Sat, 12 Dec 2020 00:10:53 GMT</pubDate>
    <dc:creator>Junyong</dc:creator>
    <dc:date>2020-12-12T00:10:53Z</dc:date>
    <item>
      <title>Number of Digits for UNIVARIATE PCTLPTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705408#M216394</link>
      <description>&lt;P&gt;I want to use PROC UNIVARIATE PCTLPTS to find the 200/4 (50th), 200/5 (40th), 200/6 (33.33th), ..., 200/400 (0.5th) percentiles as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do t=1 to 10;
do i=1 to 10000;
x=rannor(1);
output;
end;
end;
run;

proc iml;
i=200/(4:400);
call symputx("i",rowcat(char(i,16,14)+" "));
quit;

proc univariate noprint;
var x;
output pctlpre=x pctlpts=&amp;amp;i out=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And I realized that PCTLPTS accepts maximum two digits—for example, PCTLPTS cannot separately find the 200/150 (1.333th) and 200/151 (1.325th) percentiles because PCTLPTS recognizes both as 1.33. Do I have other alternatives to do this?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 23:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705408#M216394</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-12-11T23:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Number of Digits for UNIVARIATE PCTLPTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705417#M216396</link>
      <description>&lt;P&gt;I do not understand what the division you show means in terms of percentiles.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you see the same output for 1.325 and 1.333 then you are doing something else, probably in your MACRO variable.&lt;/P&gt;
&lt;P&gt;When I use:&lt;/P&gt;
&lt;PRE&gt;proc univariate noprint data=have;
   var x;
   output pctlpre=x pctlpts=1.333, 1.325 out=want;
run;
&lt;/PRE&gt;
&lt;P&gt;The output variable names are x1_33 and x1_32 and the associated values are different. With a small data set multiple percentiles will often have the same values if the values in the data repeat. Consider a very small set:&lt;/P&gt;
&lt;PRE&gt;data have2;
  do i=1 to 5;
     t=1;
     output;
     t=3;
     output;
  end;
run;

proc univariate  data=have2;
   var t;
   output pctlpre=t pctlpts=5 to 95 by 5 out=want;
run;
&lt;/PRE&gt;
&lt;P&gt;There are only 2 values in the data set and except where we get a percentile that breaks a tie with the value of 2 the percentiles are all 1 or 3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you think that Univariate can't do the percentile you want then&lt;/P&gt;
&lt;P&gt;1) sort the data by the variable of interest&lt;/P&gt;
&lt;P&gt;2) run it through a data step&lt;/P&gt;
&lt;P&gt;3) add a "percentile" position for each record.&lt;/P&gt;
&lt;PRE&gt;data have3;
  do t= 1 to 13;&lt;BR /&gt;     output;&lt;BR /&gt;  end;
run;
proc sort data=have3;
   by t;
run;
data want;
   set have3 nobs=cnt;
   pct = 100*( _n_/cnt);
run;&lt;/PRE&gt;
&lt;P&gt;So any "percentile" in the above that you request below 7.6923076923 is going to return 1.&lt;/P&gt;
&lt;P&gt;For any given "percentile" you would look for the record with the first pct value greater than or equal to your value of interest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 23:19:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705417#M216396</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-11T23:19:41Z</dc:date>
    </item>
    <item>
      <title>Re: Number of Digits for UNIVARIATE PCTLPTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705418#M216399</link>
      <description>&lt;P&gt;This may not work exaclty as you want, since UNIVARIATE allows only two decimal places in the output percentile variable names. maybe the PCTLNDEC= option fixes the problem, but I'll let you play with that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, here I create a macro variable &amp;amp;P in PROC SQL which does what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do i=1 to 100000;
x=rannor(1);
output;
end;
run;

data pctlpts;
do i=4 to 400;
fraction = 200/i;
output;
end;

proc sql noprint;
    select fraction into :p separated by ' ' from pctlpts;
quit;
%put &amp;amp;=p;

proc univariate noprint data=have;
var x;
output pctlpre=x pctlpts=&amp;amp;p out=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2020 23:29:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705418#M216399</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-12-11T23:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Number of Digits for UNIVARIATE PCTLPTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705421#M216402</link>
      <description>&lt;P&gt;My previous example was incorrect—let me further simplify the problem.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
do t=1 to 5;
do i=1 to 200000;
x=rannor(1);
output;
end;
end;
run;

proc univariate noprint;
var x;
output pctlpre=x pctlpts=1.001 1.002 out=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;If a data set is large enough, then the 1.001th and 1.002th percentiles will differ—SAS returns not the latter but the error message. Is calculating these impossible with PROC UNIVARIATE?&lt;/P&gt;</description>
      <pubDate>Sat, 12 Dec 2020 00:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705421#M216402</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-12-12T00:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: Number of Digits for UNIVARIATE PCTLPTS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705422#M216403</link>
      <description>&lt;P&gt;PCTLNDEC was the solution—thanks a lot!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Dec 2020 00:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Number-of-Digits-for-UNIVARIATE-PCTLPTS/m-p/705422#M216403</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-12-12T00:13:08Z</dc:date>
    </item>
  </channel>
</rss>

