<?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: re: Data Selection by groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339845#M77568</link>
    <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes the percentiles are already calculated and are specific for each unique YearMonth and Level.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2017 01:20:29 GMT</pubDate>
    <dc:creator>twildone</dc:creator>
    <dc:date>2017-03-10T01:20:29Z</dc:date>
    <item>
      <title>re: Data Selection by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339784#M77554</link>
      <description>&lt;P&gt;Hi....I have a dataset&amp;nbsp;that I am &amp;nbsp;trying to select a certain percentile of records based on their Fees for each YearMonth and within each Level. For example, from the table below, for the YearMonth = 201501 and Level=A, I would like to select and keep 93% of the records with the&amp;nbsp;lowest fees and exclude the remaining 7% of&amp;nbsp;the records with the highest fees. That would mean if there were 1,000 records having YearMonth = 201501 and Level =A, then I am expecting to have 930 records with YearMonth = 201501 and Level =A while the remaining 70 are excluded from the new dataset. I have sorted the dataset by YearMonth, Level and Fees. I was wondering what be the best and most efficient approach to achiev this. Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="203"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="75"&gt;YearMonth&lt;/TD&gt;
&lt;TD width="64"&gt;Level&lt;/TD&gt;
&lt;TD width="64"&gt;Percentile&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;201501&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;0.93&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;201501&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;0.95&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;201502&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;0.92&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;201503&lt;/TD&gt;
&lt;TD&gt;A&lt;/TD&gt;
&lt;TD&gt;0.92&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;201503&lt;/TD&gt;
&lt;TD&gt;B&lt;/TD&gt;
&lt;TD&gt;0.91&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;201503&lt;/TD&gt;
&lt;TD&gt;C&lt;/TD&gt;
&lt;TD&gt;0.94&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 09 Mar 2017 21:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339784#M77554</guid>
      <dc:creator>twildone</dc:creator>
      <dc:date>2017-03-09T21:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: re: Data Selection by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339786#M77555</link>
      <description>&lt;P&gt;Do you have the percentiles already calculated?&lt;/P&gt;
&lt;P&gt;If not, use PROC RANK with groups=100 and from the output select the desired records. I think it would be rank&amp;lt;92 because ranks go from 0 to 99.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 21:23:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339786#M77555</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-09T21:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: re: Data Selection by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339822#M77560</link>
      <description>&lt;P&gt;Another approach would be to use Proc Surveyselect. You can use a data set with the percentiles as a control data set but the Percentile value &lt;STRONG&gt;must&lt;/STRONG&gt; be in a variable named &lt;STRONG&gt;_RATE_&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;The procedure call would look something like this:&lt;/P&gt;
&lt;PRE&gt;proc survey select data=have out=want 
    samprate=Percentileset;
    by Yearmonth level;
run;&lt;/PRE&gt;
&lt;P&gt;where Percentileset would be the name of the data set with YearMonth, Level and _rate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both your full dataset (fees?) and Percentileset would need to be sorted by Yearmonth and level.&lt;/P&gt;
&lt;P&gt;This will give you a random selection of records.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 23:10:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339822#M77560</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-09T23:10:10Z</dc:date>
    </item>
    <item>
      <title>Re: re: Data Selection by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339845#M77568</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes the percentiles are already calculated and are specific for each unique YearMonth and Level.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 01:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339845#M77568</guid>
      <dc:creator>twildone</dc:creator>
      <dc:date>2017-03-10T01:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: re: Data Selection by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339849#M77570</link>
      <description>&lt;P&gt;Hi Ballardw.....unfortunately I need to select the lowest X percentile of the records for each YearMonth and Level and not a random sample....unless I am missing something from your approach.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 01:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339849#M77570</guid>
      <dc:creator>twildone</dc:creator>
      <dc:date>2017-03-10T01:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: re: Data Selection by groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339858#M77574</link>
      <description>&lt;P&gt;If the percentiles are already calculated isn't that just a WHERE or IF statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not for some reason, detail your issue.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 02:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/re-Data-Selection-by-groups/m-p/339858#M77574</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-10T02:35:35Z</dc:date>
    </item>
  </channel>
</rss>

