<?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: New sub-dataset where values in column are the top 25% of initial dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/New-sub-dataset-where-the-values-are-the-top-25-of-initial/m-p/789061#M252442</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I assume you want the top 25 percentile (rather than top 25%, I don't know what that means).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=have groups=4 out=want (where = (rank=3)) descending;
    var yourvariablename;
    ranks rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want any record in WANT where variable RANK is equal to zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Note you can modify&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;solution with a WHERE statement to have the data filtered.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Percentiles and 25% of data don't necessarily align though so you should be clear on the differences and if it meets your needs, especially if you have ties in your data.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 08 Jan 2022 18:30:40 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-01-08T18:30:40Z</dc:date>
    <item>
      <title>New sub-dataset where the values are the top 25% of initial dataset column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-sub-dataset-where-the-values-are-the-top-25-of-initial/m-p/789025#M252423</link>
      <description>&lt;P&gt;Thus, filtering away the lowest 75%, based on a particular variable, and leaving just the top 25% in the new sub-dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we actually use the "where" clause for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wondering how you folks might handle it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
where
top_25_percent_in_column = ??? ;&lt;BR /&gt;run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Perhaps there isn't currently a SAS 'function' for such a purpose?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you feel SAS is a bit function-lacking, say so.&amp;nbsp; Can the equivalent be found by using Python or R within SAS?&amp;nbsp; Never tried using either in SAS, but I understand there are thousands of Python and R functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thoughts appreciated....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jan 2022 11:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-sub-dataset-where-the-values-are-the-top-25-of-initial/m-p/789025#M252423</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2022-01-08T11:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: New sub-dataset where values in column are the top 25% of initial dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-sub-dataset-where-the-values-are-the-top-25-of-initial/m-p/789026#M252424</link>
      <description>&lt;P&gt;I assume you want the top 25 percentile (rather than top 25%, I don't know what that means).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=have groups=4 out=want descending;
    var yourvariablename;
    ranks rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want any record in WANT where variable RANK is equal to zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jan 2022 13:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-sub-dataset-where-the-values-are-the-top-25-of-initial/m-p/789026#M252424</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-08T13:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: New sub-dataset where the values are the top 25% of initial dataset column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-sub-dataset-where-the-values-are-the-top-25-of-initial/m-p/789032#M252426</link>
      <description>&lt;P&gt;Paige already gave you a solution.&lt;/P&gt;
&lt;P&gt;Another way is calcualted Q3 firstly and keep the top 25% via it .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set sashelp.heart;
run;

proc summary data=have;
var weight;
output out=Q3 q3=q3;
run;

data want;
 set have;
 if _n_=1 then set q3(keep=q3);
 if weight&amp;gt;=q3 ;
 drop q3;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Jan 2022 12:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-sub-dataset-where-the-values-are-the-top-25-of-initial/m-p/789032#M252426</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-08T12:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: New sub-dataset where values in column are the top 25% of initial dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-sub-dataset-where-the-values-are-the-top-25-of-initial/m-p/789061#M252442</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I assume you want the top 25 percentile (rather than top 25%, I don't know what that means).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=have groups=4 out=want (where = (rank=3)) descending;
    var yourvariablename;
    ranks rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want any record in WANT where variable RANK is equal to zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Note you can modify&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;solution with a WHERE statement to have the data filtered.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Percentiles and 25% of data don't necessarily align though so you should be clear on the differences and if it meets your needs, especially if you have ties in your data.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jan 2022 18:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-sub-dataset-where-the-values-are-the-top-25-of-initial/m-p/789061#M252442</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-08T18:30:40Z</dc:date>
    </item>
  </channel>
</rss>

