<?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: percentiles P5,P10,P20,P30,P40,P50,P60,P70,P80,P90,P95 and classify to group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948276#M371063</link>
    <description>&lt;P&gt;I am using it on my data set and I dont get the whole percentiles that I ask .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc rank data=temp(Where=(revenue&amp;gt;0)) out=want groups=100;
var revenue;
ranks rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 20 Oct 2024 12:12:02 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2024-10-20T12:12:02Z</dc:date>
    <item>
      <title>percentiles P5,P10,P20,P30,P40,P50,P60,P70,P80,P90,P95 and classify to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948254#M371050</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to calculate following percentiles and then classify each row into a group.&lt;/P&gt;
&lt;P&gt;I want to define groups (Ranks) based on following percentiles-&lt;/P&gt;
&lt;P&gt;P5,P10,P20,P30,P40,P50,P60,P70,P80,P90,P95&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following code&amp;nbsp; create the percentiles-P10,P20,P30,P40,P50,P60,P70,P80,P90&amp;nbsp; &amp;nbsp;but no P5,P95&lt;/P&gt;
&lt;P&gt;What is the way to add them???&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=sashelp.cars out=have groups=10;
var invoice;
ranks rank;
run;


proc sql;
create table rank_groups_Definition as
select rank,
		min(invoice) as min,
		max(invoice) as max
from have
group by rank
;
quit;


data rank_groups_Definition_2;
set rank_groups_Definition;
_MIN_=lag(max)+1;
IF _MIN_=. then _MIN_=0;
drop min;
rename _min_=min;
Run;


proc sql;
create table want as
select a.*,b.rank
from sashelp.cars as a
left join rank_groups_Definition_2 as b
on    b.Min&amp;lt;=a.invoice&amp;lt;=b.Max
;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Oct 2024 18:46:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948254#M371050</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-10-19T18:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: percentiles P5,P10,P20,P30,P40,P50,P60,P70,P80,P90,P95 and classify to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948257#M371053</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=sashelp.cars out=have fraction;
var invoice;
ranks rank;
run;

proc format;
	value percentile 0-&amp;lt;0.05="&amp;lt; 5 percentile"
	    0.05-&amp;lt;0.1='5-10 percentile'
	    0.1-&amp;lt;0.2='10-20 percentile'
	    /* I'm lazy, you type the rest */
	    ...
    ;
run;

proc datasets library=work nolist;
    modify have;
    format rank percentile.;
run;&amp;nbsp;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, stay away from mathematical analyses in SQL steps when possible. In the long run, SQL is a poor choice for math. Just because you can do things in SQL does not mean you should do things in SQL. In this case and many others, PROC FORMAT is a better solution. Using PROC FORMAT allows you to put labels on the group that actually mean something to humans and it keeps the variable numeric (instead of 'P5' 'P10' etc.) so it will sort numerically in tables (instead of sorting alphabetically).&lt;/P&gt;</description>
      <pubDate>Sat, 19 Oct 2024 19:54:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948257#M371053</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-19T19:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: percentiles P5,P10,P20,P30,P40,P50,P60,P70,P80,P90,P95 and classify to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948263#M371057</link>
      <description>&lt;P&gt;Split your data into 100 groups. And recode it as your wish.&lt;BR /&gt;&lt;BR /&gt;proc rank data=sashelp.cars out=have groups=100;&lt;BR /&gt;var invoice;&lt;BR /&gt;ranks rank;&lt;BR /&gt;run;&lt;BR /&gt;data have;&lt;BR /&gt;set have;&lt;BR /&gt;if rank&amp;lt;=4 then want='P5 ';&lt;BR /&gt;else if rank&amp;lt;=9 then want='P10 ';&lt;BR /&gt;else if rank&amp;lt;=19 then want='P20 ';&lt;BR /&gt;.........................&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Oct 2024 01:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948263#M371057</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-10-20T01:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: percentiles P5,P10,P20,P30,P40,P50,P60,P70,P80,P90,P95 and classify to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948276#M371063</link>
      <description>&lt;P&gt;I am using it on my data set and I dont get the whole percentiles that I ask .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc rank data=temp(Where=(revenue&amp;gt;0)) out=want groups=100;
var revenue;
ranks rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Oct 2024 12:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948276#M371063</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-10-20T12:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: percentiles P5,P10,P20,P30,P40,P50,P60,P70,P80,P90,P95 and classify to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948281#M371066</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am using it on my data set and I dont get the whole percentiles that I ask .&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What does that mean?&lt;/P&gt;</description>
      <pubDate>Sun, 20 Oct 2024 13:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948281#M371066</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-20T13:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: percentiles P5,P10,P20,P30,P40,P50,P60,P70,P80,P90,P95 and classify to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948293#M371072</link>
      <description>&lt;P&gt;Show the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't have &lt;STRIKE&gt;more than&lt;/STRIKE&gt; at least 100 non-missing non-tied values in the input set you are not going to get 100 ranks. Period.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 15:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948293#M371072</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-10-21T15:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: percentiles P5,P10,P20,P30,P40,P50,P60,P70,P80,P90,P95 and classify to group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948299#M371073</link>
      <description>As Ballardw said ,maybe your data do not have unique 100 value , Try groups=20:&lt;BR /&gt;&lt;BR /&gt;proc rank data=sashelp.cars out=have groups=20;&lt;BR /&gt;var invoice;&lt;BR /&gt;ranks rank;&lt;BR /&gt;run;&lt;BR /&gt;data have;&lt;BR /&gt;set have;&lt;BR /&gt;if rank=0 then want='P5 ';&lt;BR /&gt;else if rank=1 then want='P10 ';&lt;BR /&gt;else if rank in (2 3)  then want='P20 ';&lt;BR /&gt;.........................</description>
      <pubDate>Mon, 21 Oct 2024 00:37:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/percentiles-P5-P10-P20-P30-P40-P50-P60-P70-P80-P90-P95-and/m-p/948299#M371073</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-10-21T00:37:10Z</dc:date>
    </item>
  </channel>
</rss>

