<?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: Proc SQL Doing a Rank syntax in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605876#M175864</link>
    <description>&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Manager&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATE&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15NOV2019&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13NOV2019&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Crane, Frasier&amp;nbsp; &amp;nbsp;3NOV2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want to get the following out put in a another table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Manager&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RANK&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15NOV2019&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13NOV2019&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Crane, Frasier&amp;nbsp; &amp;nbsp;3NOV2019&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;</description>
    <pubDate>Wed, 20 Nov 2019 18:32:36 GMT</pubDate>
    <dc:creator>Jyuen204</dc:creator>
    <dc:date>2019-11-20T18:32:36Z</dc:date>
    <item>
      <title>Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605864#M175857</link>
      <description>&lt;P&gt;I have a table where I have an AGENT_ID, AGENT_NAME, TEAM_LEAD_NM, DATE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use Proc SQL to generate a rank because the ID and NAME are duplicated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select AGENT_ID, AGENT_NAME, TEAM_LEAD_NM, rank() over (Partition by AGENT_LAN_ID
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;order by sys_load_dtm desc) as RANK
from TABLE
where AGENT_NAME = 'Smith, John';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error i get is:&lt;/P&gt;&lt;P&gt;____&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, ?, AND, BETWEEN,&lt;BR /&gt;CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what is the proper syntax in PROC SQL to rank my data?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605864#M175857</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2019-11-20T18:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605866#M175858</link>
      <description>&lt;P&gt;Use PROC RANK and not PROC SQL&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=p0le3p5ngj1zlbn1mh3tistq9t76.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=p0le3p5ngj1zlbn1mh3tistq9t76.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605866#M175858</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-20T18:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605867#M175859</link>
      <description>&lt;P&gt;I am trying to build a table of of this select statement.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605867#M175859</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2019-11-20T18:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605869#M175860</link>
      <description>&lt;P&gt;Rank over is not available in PROC SQL.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605869#M175860</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-11-20T18:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605872#M175861</link>
      <description>&lt;P&gt;Is there any other method in doing this within SAS?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605872#M175861</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2019-11-20T18:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605873#M175862</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263957"&gt;@Jyuen204&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there any other method in doing this within SAS?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes I mentioned a method in my earlier reply and provided a link to the documentation (which includes examples of code)&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605873#M175862</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-20T18:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605874#M175863</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263957"&gt;@Jyuen204&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there any other method in doing this within SAS?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Almost certainly more than one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might help to show some starting data and what you expect the result to be when finished.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605874#M175863</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-20T18:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605876#M175864</link>
      <description>&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Manager&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATE&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15NOV2019&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13NOV2019&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Crane, Frasier&amp;nbsp; &amp;nbsp;3NOV2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want to get the following out put in a another table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Manager&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RANK&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15NOV2019&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13NOV2019&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Crane, Frasier&amp;nbsp; &amp;nbsp;3NOV2019&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605876#M175864</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2019-11-20T18:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605879#M175866</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm afraid this doesn't explain anything. How are these rankings computed?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Or are they simply sequence numbers, not true rankings?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605879#M175866</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-20T18:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605887#M175870</link>
      <description>That's the data within my table, I need to rank the data an place into another table (in the ranked format above.&lt;BR /&gt;I am ranking by date descending</description>
      <pubDate>Wed, 20 Nov 2019 18:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605887#M175870</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2019-11-20T18:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605888#M175871</link>
      <description>&lt;P&gt;So you are essentially asking for sequence numbers? (assuming you have sorted the data by descending date).&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 18:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605888#M175871</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-20T18:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605889#M175872</link>
      <description>Well my data isnt as clean as I am going to have multiple names and multiple dates</description>
      <pubDate>Wed, 20 Nov 2019 19:01:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605889#M175872</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2019-11-20T19:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605891#M175874</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263957"&gt;@Jyuen204&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Manager&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATE&lt;/P&gt;
&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15NOV2019&lt;/P&gt;
&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13NOV2019&lt;/P&gt;
&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Crane, Frasier&amp;nbsp; &amp;nbsp;3NOV2019&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Want to get the following out put in a another table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Manager&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RANK&lt;/P&gt;
&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15NOV2019&amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13NOV2019&amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Crane, Frasier&amp;nbsp; &amp;nbsp;3NOV2019&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What is your definition of RANK?&amp;nbsp; Are you just counting observations?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by id descending date;
  if first.id then rank=0;
  rank+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Counting distinct dates?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by id descending date;
  if first.id then rank=0;
  rank+first.date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Nov 2019 19:06:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605891#M175874</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-20T19:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605892#M175875</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TABLE1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Manager&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATE&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15NOV2019&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13NOV2019&lt;/P&gt;&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Crane, Frasier&amp;nbsp; &amp;nbsp;3NOV2019&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am needing to rank a table of data like here. so that the most recent date is ranked the highest.&lt;/P&gt;&lt;P&gt;I need to create a secondary table of this data where RANK = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so of the data examples above, I want to rank the data in the table, and create a table of the rank 1 rows.&lt;/P&gt;&lt;P&gt;So I am only left with :&lt;BR /&gt;XXX1&amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; Doe, Jane&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 19:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605892#M175875</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2019-11-20T19:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605893#M175876</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263957"&gt;@Jyuen204&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Well my data isnt as clean as I am going to have multiple names and multiple dates&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This doesn't explain anything, and it doesn't answer my question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Give us a small example of the un-clean data, and show us and explain to us what you want to do with it.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 19:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605893#M175876</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-20T19:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605894#M175877</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263957"&gt;@Jyuen204&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TABLE1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Manager&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATE&lt;/P&gt;
&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15NOV2019&lt;/P&gt;
&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Doe, Jane&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13NOV2019&lt;/P&gt;
&lt;P&gt;XXX1&amp;nbsp; &amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; &amp;nbsp;Crane, Frasier&amp;nbsp; &amp;nbsp;3NOV2019&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am needing to rank a table of data like here. so that the most recent date is ranked the highest.&lt;/P&gt;
&lt;P&gt;I need to create a secondary table of this data where RANK = 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so of the data examples above, I want to rank the data in the table, and create a table of the rank 1 rows.&lt;/P&gt;
&lt;P&gt;So I am only left with :&lt;BR /&gt;XXX1&amp;nbsp; &amp;nbsp;Smith, John&amp;nbsp; &amp;nbsp; Doe, Jane&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yet another reason not to use SQL. With a data step you can generate two datasets in one step (if you really need them).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data all most_recent;
  set have;
  by id descending date;
  if first.id then rank=0;
  rank+1;
  if rank=1 then output most_recent;
  output all;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Nov 2019 19:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605894#M175877</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-20T19:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605895#M175878</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263957"&gt;@Jyuen204&lt;/a&gt;&amp;nbsp; If I understand you correctly, you want to compute rank using PROC SQL ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input ID     $      Name     &amp;amp; $20.         Manager &amp;amp; $20. DATE:date9.;
format date date9.;
cards;
XXX1     Smith, John     Doe, Jane         15NOV2019
XXX1     Smith, John     Doe, Jane         13NOV2019
XXX1     Smith, John     Crane, Frasier   3NOV2019
;

proc sql;
create table want as
select a.*,count(b.date) as rank
from have a, have b
where a.id=b.id and a.date&amp;lt;=b.date
group by a.id,a.name,a.manager,a.date
order by id,rank;
quit;

proc print noobs;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;ID&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;Name&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;Manager&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;DATE&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;rank&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;XXX1&lt;/TD&gt;
&lt;TD class="l data"&gt;Smith, John&lt;/TD&gt;
&lt;TD class="l data"&gt;Doe, Jane&lt;/TD&gt;
&lt;TD class="r data"&gt;15NOV2019&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;XXX1&lt;/TD&gt;
&lt;TD class="l data"&gt;Smith, John&lt;/TD&gt;
&lt;TD class="l data"&gt;Doe, Jane&lt;/TD&gt;
&lt;TD class="r data"&gt;13NOV2019&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;XXX1&lt;/TD&gt;
&lt;TD class="l data"&gt;Smith, John&lt;/TD&gt;
&lt;TD class="l data"&gt;Crane, Frasier&lt;/TD&gt;
&lt;TD class="r data"&gt;03NOV2019&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 20 Nov 2019 19:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605895#M175878</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-20T19:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605900#M175879</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/263957"&gt;@Jyuen204&lt;/a&gt;&amp;nbsp; If I understand you correctly, you want to compute rank using PROC SQL ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input ID     $      Name     &amp;amp; $20.         Manager &amp;amp; $20. DATE:date9.;
format date date9.;
cards;
XXX1     Smith, John     Doe, Jane         15NOV2019
XXX1     Smith, John     Doe, Jane         13NOV2019
XXX1     Smith, John     Crane, Frasier   3NOV2019
;

proc sql;
create table want as
select a.*,count(b.date) as rank
from have a, have b
where a.id=b.id and a.date&amp;lt;=b.date
group by a.id,a.name,a.manager,a.date
order by id,rank;
quit;

proc print noobs;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="l header" scope="col"&gt;ID&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;Name&lt;/TH&gt;
&lt;TH class="l header" scope="col"&gt;Manager&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;DATE&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;rank&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;XXX1&lt;/TD&gt;
&lt;TD class="l data"&gt;Smith, John&lt;/TD&gt;
&lt;TD class="l data"&gt;Doe, Jane&lt;/TD&gt;
&lt;TD class="r data"&gt;15NOV2019&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;XXX1&lt;/TD&gt;
&lt;TD class="l data"&gt;Smith, John&lt;/TD&gt;
&lt;TD class="l data"&gt;Doe, Jane&lt;/TD&gt;
&lt;TD class="r data"&gt;13NOV2019&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;XXX1&lt;/TD&gt;
&lt;TD class="l data"&gt;Smith, John&lt;/TD&gt;
&lt;TD class="l data"&gt;Crane, Frasier&lt;/TD&gt;
&lt;TD class="r data"&gt;03NOV2019&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What about the case of ties, where two records have the same date? I'm not sure I want to use this code in the case of ties, as I don't like the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, the original poster ought to weigh in on this, and specify if ties can happen, and what should happen in the case of ties. PROC RANK gives you many options to handle ties.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 19:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605900#M175879</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-20T19:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605904#M175880</link>
      <description>&lt;P&gt;If my table is names TableX how do i reference this in your example to get the data?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2019 19:34:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605904#M175880</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2019-11-20T19:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Doing a Rank syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605906#M175881</link>
      <description>i am assuming "have" is the table name you are using in reference to my TABLE1?</description>
      <pubDate>Wed, 20 Nov 2019 19:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Doing-a-Rank-syntax/m-p/605906#M175881</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2019-11-20T19:36:09Z</dc:date>
    </item>
  </channel>
</rss>

