<?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: Identifying top 10 scoring observations in a way that permits tied observations to be included in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-top-10-scoring-observations-in-a-way-that-permits/m-p/884946#M349636</link>
    <description>&lt;P&gt;Use PROC RANK to identify top X observations, including ties. I guess you could write DATA step code to do this, but why bother when SAS has already given you the tools to do it very quickly and easily?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=have descending ties=low out=want;
    var x;
    ranks x_ranked;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;If TIES=LOW isn't what you want, there are other options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1689535655649.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85807i1C596CB78A858099/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_0-1689535655649.png" alt="PaigeMiller_0-1689535655649.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Jul 2023 19:28:13 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-07-16T19:28:13Z</dc:date>
    <item>
      <title>Identifying top 10 scoring observations in a way that permits tied observations to be included</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-top-10-scoring-observations-in-a-way-that-permits/m-p/884936#M349630</link>
      <description>&lt;P&gt;Hello Fellow SAS Programmers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to classify ranked observations in my dataset. I am interested in identifying the top 10 performing observations. The challenge is that there can potentially be tied values among more than the top 10 performing observations.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my dataset, I have performance score (X variable) for each of 270 observations. Some observations have the same score. After I conduct a descending sort of the file using the variable X,&amp;nbsp; I&amp;nbsp;&amp;nbsp;want to identify the top 10 scoring observations in a way that permits tied observations can be included in the top 10 performance category (i.e., Top_10 = 'Yes').&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below, I display an example of what I am trying to achieve.&amp;nbsp; Can someone please help me by suggesting SAS code that can achieve what I want. It would be great if it were part of a data step, but it doesn't have to be. For instance, I could probably create a file that has no duplicate performance scores, then create a counting variable, and then merge that file with the initial dataset.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;X&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Top_10&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 99&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 90&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 83&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 83&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 72&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 71&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 71&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 65&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 52&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 43&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Yes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Rover17&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jul 2023 17:50:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-top-10-scoring-observations-in-a-way-that-permits/m-p/884936#M349630</guid>
      <dc:creator>Rover17</dc:creator>
      <dc:date>2023-07-16T17:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying top 10 scoring observations in a way that permits tied observations to be included</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-top-10-scoring-observations-in-a-way-that-permits/m-p/884944#M349634</link>
      <description>&lt;P&gt;Hi.&amp;nbsp;&amp;nbsp;Consider this sample program.&lt;/P&gt;
&lt;P&gt;/* Create a sample table that is ordered By descending X*/&lt;BR /&gt;Data Sample;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input X ;&lt;BR /&gt;datalines;&lt;BR /&gt;99 &lt;BR /&gt;90 &lt;BR /&gt;83 &lt;BR /&gt;83 &lt;BR /&gt;72 &lt;BR /&gt;71 &lt;BR /&gt;71 &lt;BR /&gt;65 &lt;BR /&gt;52 &lt;BR /&gt;43 &lt;BR /&gt;31 &lt;BR /&gt;20 &lt;BR /&gt;20 &lt;BR /&gt;19&lt;BR /&gt;18 &lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;/* Count 1 for a single BY value and for count 1 for duplicate BY values*/&lt;BR /&gt;data Top10;&lt;BR /&gt;set sample;&lt;BR /&gt;by descending x;&lt;BR /&gt;If last.x then count+1;&lt;BR /&gt;if count&amp;lt;=10 then do;&lt;BR /&gt;Top10='Yes';&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;else do;&lt;BR /&gt;Top10='No';&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc print data=top10;&lt;BR /&gt;title "Counting duplicates as 1 in Tp 10 table";&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jul 2023 19:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-top-10-scoring-observations-in-a-way-that-permits/m-p/884944#M349634</guid>
      <dc:creator>john_mccall</dc:creator>
      <dc:date>2023-07-16T19:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying top 10 scoring observations in a way that permits tied observations to be included</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-top-10-scoring-observations-in-a-way-that-permits/m-p/884946#M349636</link>
      <description>&lt;P&gt;Use PROC RANK to identify top X observations, including ties. I guess you could write DATA step code to do this, but why bother when SAS has already given you the tools to do it very quickly and easily?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=have descending ties=low out=want;
    var x;
    ranks x_ranked;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;If TIES=LOW isn't what you want, there are other options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1689535655649.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85807i1C596CB78A858099/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_0-1689535655649.png" alt="PaigeMiller_0-1689535655649.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Jul 2023 19:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-top-10-scoring-observations-in-a-way-that-permits/m-p/884946#M349636</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-16T19:28:13Z</dc:date>
    </item>
  </channel>
</rss>

