<?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 equal to rank function in SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-equal-to-rank-function-in-SQL/m-p/270897#M53877</link>
    <description>&lt;P&gt;If you already have an index variable N . You can do this &amp;nbsp;like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
 set sashelp.class;
 n+1;
run;


proc sql;
 select (select count(*) from class where sex=a.sex and n&amp;lt;=a.n) as rank,a.*
  from class as a
   order by sex,n;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 17 May 2016 07:56:19 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-05-17T07:56:19Z</dc:date>
    <item>
      <title>proc sql equal to rank function in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-equal-to-rank-function-in-SQL/m-p/270707#M53829</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The RANK function in SQL is often used to dedup a dataset by specifying the first observation to keep. RANK can also be used to number records within a group. There is no clear substitute for RANK in SAS, i don't want a data step. i want a proc sql.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;SELECT a.*, RANK() over (partition by cust_id order by date_created) as n&lt;BR /&gt;FROM inputds a&lt;BR /&gt;Order by cust_id, date_created&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;====================================================&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;i want the sas proc sql equivalent to this.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Gmorla&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 15:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-equal-to-rank-function-in-SQL/m-p/270707#M53829</guid>
      <dc:creator>gmorla2016</dc:creator>
      <dc:date>2016-05-16T15:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql equal to rank function in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-equal-to-rank-function-in-SQL/m-p/270715#M53830</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84016"&gt;@gmorla2016&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;i don't want a data step. i want a proc sql.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;?..&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;i want the sas proc sql equivalent to this.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Gmorla&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at the monotonic() function which is unsupported, or use SQL pass through.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 16:03:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-equal-to-rank-function-in-SQL/m-p/270715#M53830</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-16T16:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql equal to rank function in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-equal-to-rank-function-in-SQL/m-p/270897#M53877</link>
      <description>&lt;P&gt;If you already have an index variable N . You can do this &amp;nbsp;like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
 set sashelp.class;
 n+1;
run;


proc sql;
 select (select count(*) from class where sex=a.sex and n&amp;lt;=a.n) as rank,a.*
  from class as a
   order by sex,n;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 May 2016 07:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-equal-to-rank-function-in-SQL/m-p/270897#M53877</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-05-17T07:56:19Z</dc:date>
    </item>
  </channel>
</rss>

