<?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: Help in Rank function -Proc SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379486#M91358</link>
    <description>Thank you! I already did this in SAS, but trying to do in Proc SQL.</description>
    <pubDate>Wed, 26 Jul 2017 17:37:16 GMT</pubDate>
    <dc:creator>Kalai2008</dc:creator>
    <dc:date>2017-07-26T17:37:16Z</dc:date>
    <item>
      <title>Help in Rank function -Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379473#M91349</link>
      <description>&lt;P&gt;I would like to use the Rank function in Proc sql&lt;/P&gt;&lt;P&gt;Getting error, when I use this code&lt;/P&gt;&lt;P&gt;RANK() OVER(ORDER BY t.ID DESC) as rank,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Output like this,&lt;/P&gt;&lt;P&gt;ID New col&lt;BR /&gt;10 1&lt;BR /&gt;10 2&lt;BR /&gt;10 3&lt;BR /&gt;23 1&lt;BR /&gt;25 1&lt;BR /&gt;45 1&lt;BR /&gt;50 1&lt;BR /&gt;50 2&lt;BR /&gt;65 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 17:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379473#M91349</guid>
      <dc:creator>Kalai2008</dc:creator>
      <dc:date>2017-07-26T17:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Help in Rank function -Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379478#M91352</link>
      <description>&lt;P&gt;Rank over and others are known as Order analytical functions and &amp;nbsp;are not available in Proc SQL. But you can use proc sort and use first.variable concept to give rank&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id;
datalines;
10 
10 
10 
23 
25 
45 
50 
50 
65 
;

proc sort data =  have;
by id;
run;

data want;
set have;
by id;
if first.id then rank =1;
else rank+1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then use&amp;nbsp;first.ID to get the desired result in sas datastep&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 17:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379478#M91352</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2017-07-26T17:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help in Rank function -Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379481#M91354</link>
      <description>&lt;P&gt;PROC RANK will do this as well.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 17:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379481#M91354</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-26T17:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help in Rank function -Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379486#M91358</link>
      <description>Thank you! I already did this in SAS, but trying to do in Proc SQL.</description>
      <pubDate>Wed, 26 Jul 2017 17:37:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379486#M91358</guid>
      <dc:creator>Kalai2008</dc:creator>
      <dc:date>2017-07-26T17:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help in Rank function -Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379488#M91359</link>
      <description>&lt;P&gt;The following will work using proc sql:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table want as
  select *,
   (select count(distinct b.weight)
     from sashelp.class b
       where b.weight &amp;lt;= a.weight
         and a.sex eq b.sex) as rank
           from sashelp.class a
  ;
quit;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 17:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-Rank-function-Proc-SQL/m-p/379488#M91359</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-26T17:45:51Z</dc:date>
    </item>
  </channel>
</rss>

