<?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 get the highest 95% of a group? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713385#M220074</link>
    <description>&lt;P&gt;In your earlier thread, code was provided to compute the cumulative percent by group. So any observation where the cumulative percent is &amp;lt;=95% would be flagged.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jan 2021 15:46:17 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-01-22T15:46:17Z</dc:date>
    <item>
      <title>How to get the highest 95% of a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713370#M220068</link>
      <description>I have a list of numbers belonging to some groups. Dataset is sorted in descending order:&lt;BR /&gt;Group A 10&lt;BR /&gt;Group A 5&lt;BR /&gt;Group A 3&lt;BR /&gt;Group A 2&lt;BR /&gt;Group A 1&lt;BR /&gt;Group B 15&lt;BR /&gt;Group B 7&lt;BR /&gt;Group B 2&lt;BR /&gt;How do I pick those observations which belong within the top 95% or more within a particular group? Like the total of group A is 21, so the first four observations in group A will contribute to the top 95% and the first 2 observations of Group B&lt;BR /&gt;I want to create a flag against observations which satisfy this criteria . So in this case there will be a flag for first 4 obs of Group A and first 2 of Group B.&lt;BR /&gt;</description>
      <pubDate>Fri, 22 Jan 2021 15:04:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713370#M220068</guid>
      <dc:creator>Shradha1</dc:creator>
      <dc:date>2021-01-22T15:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the highest 95% of a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713384#M220073</link>
      <description>&lt;P&gt;First, you should show exactly what the desired output looks like.&lt;/P&gt;
&lt;P&gt;Second, 95% of what? Percentages involve numerators and denominators. You show 5 values in our A group. That means each value is 20% of the number of values. Or is the numeric value a count of some sort? So do you mean 95% of the total count?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data is supposed to be counts how did you make them? That could simplify you issue.&lt;/P&gt;
&lt;P&gt;Consider the results here that adds a cumulative percent when counting.&lt;/P&gt;
&lt;PRE&gt;proc sort data=sashelp.class
   out=work.class;
   by sex;
run;
proc freq data=work.class order=freq;
   by sex;
   ods output onewayfreqs=work.count;
   tables age ;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;you need to decide and describe what the result looks like when there is not a "nice" 95% boundary.&lt;/P&gt;
&lt;P&gt;It is very likely that the next to last in a sorted group is considerably less than 95 and jumps from maybe 80% to 100.&lt;/P&gt;
&lt;P&gt;And what about ties of the value?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2021 15:43:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713384#M220073</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-22T15:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the highest 95% of a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713385#M220074</link>
      <description>&lt;P&gt;In your earlier thread, code was provided to compute the cumulative percent by group. So any observation where the cumulative percent is &amp;lt;=95% would be flagged.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2021 15:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713385#M220074</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-22T15:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the highest 95% of a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713387#M220076</link>
      <description>&lt;P&gt;So I used SAShelp.CARS.&amp;nbsp; Proc means can calculate percentiles for you.&amp;nbsp; You can then merge those percentiles back&amp;nbsp; with the original dataset selecting records less than or greater than the percentile for the group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here I'm finding the MSRPs less than the 75th percentile for each Make.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MEANS DATA=SASHELP.CARS
	NOPRINT 	CHARTYPE	QMETHOD=OS NONOBS Q3	;
	VAR MSRP;
	BY Make;

  OUTPUT 	OUT=Percentiles
	  Q3()=
  	/ AUTONAME AUTOLABEL INHERIT
	;
RUN;

PROC SQL;
   CREATE TABLE wantish AS 
   SELECT CARS.Make, 
          CARS.Model, 
          CARS.MSRP
      FROM SAShelp.CARS 
             INNER JOIN 
           Percentiles p 
        ON (CARS.Make = p.Make)
      WHERE CARS.MSRP &amp;lt; p.MSRP_Q3;
QUIT;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2021 15:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713387#M220076</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-01-22T15:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the highest 95% of a group?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713391#M220078</link>
      <description>&lt;P&gt;With a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
do until(last.group);
    set have; by group;
    totValue = sum(totValue, value);
    end;
do until(last.group);
    set have; by group;
    cumValue = sum(cumValue, value);
    flag = (totValue - cumValue) &amp;gt;= 0.05 * totValue;
    output;
    end;
drop totValue cumValue;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PGStats_0-1611330687313.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53802iEC08EC2C7159FA31/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PGStats_0-1611330687313.png" alt="PGStats_0-1611330687313.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jan 2021 15:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-highest-95-of-a-group/m-p/713391#M220078</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-01-22T15:51:35Z</dc:date>
    </item>
  </channel>
</rss>

