<?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: Divide population into 10 groups by percentiles in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721508#M223651</link>
    <description>&lt;P&gt;Percentile of what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is something to get you started&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=sashelp.cars groups=10 descending out=cars;
   var MPG_City;
   ranks rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Feb 2021 09:21:31 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2021-02-24T09:21:31Z</dc:date>
    <item>
      <title>Divide population into 4 groups by percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721506#M223649</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to divide population of variable invoice in data set sashelp.cars into 4 groups by variable&amp;nbsp; invoice.&lt;/P&gt;
&lt;P&gt;In each group there will be equal number of rows .&lt;/P&gt;
&lt;P&gt;So, the criteria is using percentile .&lt;/P&gt;
&lt;P&gt;Then I need to put the values (range of values) in proc format.&lt;/P&gt;
&lt;P&gt;So, in proc format there will be defined 5 groups&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How should we do it pls?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 09:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721506#M223649</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-02-24T09:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into 10 groups by percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721508#M223651</link>
      <description>&lt;P&gt;Percentile of what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is something to get you started&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=sashelp.cars groups=10 descending out=cars;
   var MPG_City;
   ranks rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2021 09:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721508#M223651</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-02-24T09:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into 5 groups by percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721513#M223652</link>
      <description>&lt;P&gt;Here's a try with UNIVARIATE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data=sashelp.cars;
var invoice;
output
  out=Pctls
  pctlpts = 10 20 30 40 50 60 70 80 90 100
  pctlpre = invoice
  pctlname = pct10 pct20 pct30 pct40 pct50 pct60 pct70 pct80 pct90 pct100
;
run;

proc sort
  data=sashelp.cars (keep=invoice)
  out=cars
;
by invoice;
run;

proc transpose
  data=pctls
  out=p_long
;
var _all_;
run;

data cntlin;
set p_long;
fmtname = "carspct";
type = "N";
start = ifn(_n_ = 1,0,lag(col1));
end = col1;
label = catx(" ","Percentile",_n_);
keep fmtname type start end label;
run;

proc format cntlin=cntlin;
run;

data carsfmt;
set cars;
format invoice carspct.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2021 09:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721513#M223652</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-24T09:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into 4 groups by percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721515#M223653</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I don't understand why the ranges are overlapped???&lt;/P&gt;
&lt;P&gt;rank 0 is valued from 35777 &amp;nbsp;till 173560&lt;/P&gt;
&lt;P&gt;rank 1 is valued from 25371 &amp;nbsp;till&amp;nbsp;35688&lt;/P&gt;
&lt;P&gt;rank 2 is valued from 18881 &amp;nbsp;till&amp;nbsp;25218&lt;/P&gt;
&lt;P&gt;rank 3 is valued from 9875 till&amp;nbsp;18821&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;by  invoice ;run;

proc rank data=cars groups=4 descending out=cars;
   var invoice;
   ranks rank;
run;

PROC SQL;
	create table tbl  as
	select  0 as rank,
            min(invoice) as rank_min,
		    max(invoice) as rank_max
	from  cars
	where rank=0
	union all
  select  1 as rank,
            min(invoice) as rank_min,
		    max(invoice) as rank_max
	from  cars
	where rank=1
	union all
  select  2 as rank,
            min(invoice) as rank_min,
		    max(invoice) as rank_max
	from  cars
	where rank=2
		union all
  select  3 as rank,
            min(invoice) as rank_min,
		    max(invoice) as rank_max
	from  cars
	where rank=3

;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 09:56:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721515#M223653</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-02-24T09:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into 5 groups by percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721516#M223654</link>
      <description>&lt;P&gt;May you please explain why proc rand is not working well?&lt;/P&gt;
&lt;P&gt;I expect that in each group there will be non-overlapped values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;by  invoice ;run;
proc rank data=cars groups=10 descending out=cars;
   var invoice;
   ranks rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 10:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721516#M223654</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-02-24T10:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into 5 groups by percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721541#M223663</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;May you please explain why proc rand is not working well?&lt;/P&gt;
&lt;P&gt;I expect that in each group there will be non-overlapped values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;by  invoice ;run;
proc rank data=cars groups=10 descending out=cars;
   var invoice;
   ranks rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What do you mean by "not working well"? PROC RANK will not produce overlapping groupings, except in the case of ties in which case there can be (and should be) some overlap. Please show us what you are seeing that doesn't work.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 12:14:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721541#M223663</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-24T12:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into 5 groups by percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721553#M223670</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;proc sort data=sashelp.cars out=cars;by  invoice ;run;
proc rank data=cars groups=4 descending out=cars;
   var invoice;
   ranks rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can it happen that invoice value in first group is between&amp;nbsp;35777 &amp;nbsp;till 173560&lt;/P&gt;
&lt;P&gt;and&amp;nbsp;invoice value in second&amp;nbsp; group is between 25371 &amp;nbsp;till&amp;nbsp;35688&lt;/P&gt;
&lt;P&gt;I expect that minimum value in second group will be&amp;nbsp;173560 !!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 13:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721553#M223670</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-02-24T13:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into 5 groups by percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721559#M223673</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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I expect that minimum value in second group will be&amp;nbsp;173560 !!!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't understand this, why do you expect that? I expect the MAXIMUM value in the FIRST group to be 173560, and that the MINIMUM value in the first group to be less than 173560; and that the maximum value in the other groups would be less than 173560, and also less than or equal to the minimum of the previous group, and that is what I see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=sashelp.cars groups=4 descending out=cars;
    var invoice;
    ranks rank;
run;
proc summary nway data=cars;
    class rank;
    var invoice;
    output out=stats min=min_invoice max=max_invoice;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 13:48:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721559#M223673</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-24T13:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Divide population into 4 groups by percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721925#M223802</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;Hello,&lt;/P&gt;
&lt;P&gt;I don't understand why the ranges are overlapped???&lt;/P&gt;
&lt;P&gt;rank 0 is valued from 35777 &amp;nbsp;till 173560&lt;/P&gt;
&lt;P&gt;rank 1 is valued from 25371 &amp;nbsp;till&amp;nbsp;35688&lt;/P&gt;
&lt;P&gt;rank 2 is valued from 18881 &amp;nbsp;till&amp;nbsp;25218&lt;/P&gt;
&lt;P&gt;rank 3 is valued from 9875 till&amp;nbsp;18821&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What overlap? There is no overlap there. 35777 is larger than 35688, 25371 is larger than 25218, 18881 is larger than 18821.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 16:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Divide-population-into-4-groups-by-percentiles/m-p/721925#M223802</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-25T16:56:22Z</dc:date>
    </item>
  </channel>
</rss>

