<?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: Please help me to find the top three salary from emp table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540414#M149079</link>
    <description>&lt;P&gt;Sir It is the sample table&lt;/P&gt;&lt;P&gt;Data emp;&lt;BR /&gt;infile datalines truncover;&lt;BR /&gt;input id ename$ dept$ sal;&lt;BR /&gt;datalines;&lt;BR /&gt;1 A account 100&lt;BR /&gt;2 B HR 200&lt;BR /&gt;3 c Dev 400&lt;BR /&gt;4 D account 600&lt;BR /&gt;5 E account 700&lt;BR /&gt;6 F HR 500&lt;BR /&gt;7 G HR 300&lt;BR /&gt;8 H Dev 800&lt;BR /&gt;9 I Dev 250&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;select *&lt;BR /&gt;from emp&lt;BR /&gt;order by sal desc;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;SELECT monotonic() as rank, ename, sal&lt;BR /&gt;from(select ename, sal&lt;BR /&gt;from emp&lt;BR /&gt;order by sal desc)&lt;BR /&gt;where calculated rank&amp;lt;= 3;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is coming in log&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;431 Select * from (select *,monotonic()as x from emp order by sal descending) ;&lt;BR /&gt;----- -&lt;BR /&gt;79 22&lt;BR /&gt;-&lt;BR /&gt;200&lt;BR /&gt;ERROR 79-322: Expecting a ).&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, ','.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;432 quit;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just want to solve it using Pro sql.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Mar 2019 12:05:40 GMT</pubDate>
    <dc:creator>toparveenkumar</dc:creator>
    <dc:date>2019-03-05T12:05:40Z</dc:date>
    <item>
      <title>Please help me to find the top three salary from emp table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540398#M149065</link>
      <description>&lt;P&gt;I have a emp data set and want to find out the&amp;nbsp;top three salary from emp table by following code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;SELECT monotonic() as RANK, ename, sal&lt;BR /&gt;FROM (SELECT ename, sal&lt;BR /&gt;FROM emp&lt;BR /&gt;ORDER BY sal DESC)&lt;BR /&gt;WHERE&amp;nbsp; calculated RANK &amp;lt;= 3;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then Error is coming&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 79-322: Expecting a ).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help to find "top three salary from emp table" I will be very thankful to you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 10:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540398#M149065</guid>
      <dc:creator>toparveenkumar</dc:creator>
      <dc:date>2019-03-05T10:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Please help me to find the top three salary from emp table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540404#M149069</link>
      <description>&lt;P&gt;Some tips:&lt;/P&gt;
&lt;P&gt;Don't use monotonic(), its not production.&lt;/P&gt;
&lt;P&gt;Don't code in uppercase, its like shouting.&lt;/P&gt;
&lt;P&gt;See here for a better solution:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Calculate-the-highest-two-records-of-Metrc2-for-each-date/m-p/497108/highlight/true#M131644" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Calculate-the-highest-two-records-of-Metrc2-for-each-date/m-p/497108/highlight/true#M131644&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As for your code I can't check, post the exact log of the run.&amp;nbsp; Nothing jumps out at me, but without something to check against...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 11:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540404#M149069</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-03-05T11:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Please help me to find the top three salary from emp table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540414#M149079</link>
      <description>&lt;P&gt;Sir It is the sample table&lt;/P&gt;&lt;P&gt;Data emp;&lt;BR /&gt;infile datalines truncover;&lt;BR /&gt;input id ename$ dept$ sal;&lt;BR /&gt;datalines;&lt;BR /&gt;1 A account 100&lt;BR /&gt;2 B HR 200&lt;BR /&gt;3 c Dev 400&lt;BR /&gt;4 D account 600&lt;BR /&gt;5 E account 700&lt;BR /&gt;6 F HR 500&lt;BR /&gt;7 G HR 300&lt;BR /&gt;8 H Dev 800&lt;BR /&gt;9 I Dev 250&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;select *&lt;BR /&gt;from emp&lt;BR /&gt;order by sal desc;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;SELECT monotonic() as rank, ename, sal&lt;BR /&gt;from(select ename, sal&lt;BR /&gt;from emp&lt;BR /&gt;order by sal desc)&lt;BR /&gt;where calculated rank&amp;lt;= 3;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is coming in log&lt;/P&gt;&lt;P&gt;Proc sql;&lt;BR /&gt;431 Select * from (select *,monotonic()as x from emp order by sal descending) ;&lt;BR /&gt;----- -&lt;BR /&gt;79 22&lt;BR /&gt;-&lt;BR /&gt;200&lt;BR /&gt;ERROR 79-322: Expecting a ).&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, ','.&lt;/P&gt;&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;432 quit;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just want to solve it using Pro sql.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 12:05:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540414#M149079</guid>
      <dc:creator>toparveenkumar</dc:creator>
      <dc:date>2019-03-05T12:05:40Z</dc:date>
    </item>
    <item>
      <title>Re: Please help me to find the top three salary from emp table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540417#M149081</link>
      <description>&lt;P&gt;Yes, so Order by is not valid in subqueries.&amp;nbsp; Has been covered before:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Procedures/order-by-in-subquery/td-p/15483" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/order-by-in-subquery/td-p/15483&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As I noted before, use the procedure mentioned in that post.&amp;nbsp; Also, using Base SAS in SAS (it is the programming language you are using) will make your code simpler, easier to maintain and faster.&amp;nbsp; Use SQL only when it adds something to the whole.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 12:29:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540417#M149081</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-03-05T12:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Please help me to find the top three salary from emp table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540465#M149100</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SQL statement &lt;CODE&gt;reset OUTOBS=n;&lt;/CODE&gt; sets the &lt;CODE&gt;OUTOBS&lt;/CODE&gt; option that restricts the &lt;STRONG&gt;number of rows&lt;/STRONG&gt; selected for output.&amp;nbsp; The option applies to all subsequent queries in the SQL step, and can be reset to all rows using &lt;CODE&gt;reset OUTOBS=MAX;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  reset outobs=3;

  create table top3priced_cars as
  select * from sashelp.cars
  order by MSRP descending;
quit;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;Caution: The option does not affect sub-queries. This query will show N=428.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  create table top3priced_cars as
  select make, model, MSRP, count(*) as N from 
  ( select * from sashelp.cars ); &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy coding.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 15:08:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540465#M149100</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2019-03-05T15:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Please help me to find the top three salary from emp table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540662#M149184</link>
      <description>&lt;P&gt;Thanks a lot to all of You.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 06:47:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-me-to-find-the-top-three-salary-from-emp-table/m-p/540662#M149184</guid>
      <dc:creator>toparveenkumar</dc:creator>
      <dc:date>2019-03-06T06:47:41Z</dc:date>
    </item>
  </channel>
</rss>

