<?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: Problem when using order by in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888078#M350886</link>
    <description>&lt;P&gt;Thank you! You are right it is this problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This time since it still gave me output, so I did not think there would be a problem and did not check the log. In the log, there is indeed this error. Next time I would check log anyway!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 06 Aug 2023 21:41:24 GMT</pubDate>
    <dc:creator>Eileen1496</dc:creator>
    <dc:date>2023-08-06T21:41:24Z</dc:date>
    <item>
      <title>Problem when using order by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888075#M350883</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm new to SAS. I was trying the order by function using a dataset from sashelp library (sashelp.cars). I want to sort by msrp in ascending order. However, as I run my code, it does not sort msrp in ascending order. I could not find any mistakes in my code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me find out what happens?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;PRE&gt;proc sql;
select cars.make, cars.model, cars.msrp as tax
from sashelp.cars
where msrp&amp;lt;=40000;
order by msrp;
quit;&lt;/PRE&gt;</description>
      <pubDate>Sun, 06 Aug 2023 20:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888075#M350883</guid>
      <dc:creator>Eileen1496</dc:creator>
      <dc:date>2023-08-06T20:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when using order by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888076#M350884</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446510"&gt;@Eileen1496&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remove the semicolon after the WHERE clause. Otherwise the ORDER BY clause is not part of the query and causes a syntax error (did you see the message in the log?).&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 21:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888076#M350884</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-08-06T21:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when using order by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888077#M350885</link>
      <description>&lt;P&gt;It is best to show the LOG when discussing code.&lt;/P&gt;
&lt;P&gt;In the case of what you posted it clearly shows an error.&lt;/P&gt;
&lt;PRE&gt; proc sql;
8    select cars.make, cars.model, cars.msrp as tax
9    from sashelp.cars
10   where msrp&amp;lt;=40000;
NOTE: Writing HTML Body file: sashtml.htm
11   order by msrp;
     -----
     180
ERROR 180-322: Statement is not valid or it is used out of proper order.

12   quit;
&lt;/PRE&gt;
&lt;P&gt;The semicolon at the end of the Where clause ends the SELECT. So the Order By starts a new statement and is not legal as the first clause of a query.&lt;/P&gt;
&lt;P&gt;Remove the semicolon after the Where msrp&amp;lt;=40000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446510"&gt;@Eileen1496&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;I'm new to SAS. I was trying the order by function using a dataset from sashelp library (sashelp.cars). I want to sort by msrp in ascending order. However, as I run my code, it does not sort msrp in ascending order. I could not find any mistakes in my code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you help me find out what happens?&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code:&lt;/P&gt;
&lt;PRE&gt;proc sql;
select cars.make, cars.model, cars.msrp as tax
from sashelp.cars
where msrp&amp;lt;=40000;
order by msrp;
quit;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 21:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888077#M350885</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-08-06T21:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when using order by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888078#M350886</link>
      <description>&lt;P&gt;Thank you! You are right it is this problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This time since it still gave me output, so I did not think there would be a problem and did not check the log. In the log, there is indeed this error. Next time I would check log anyway!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 21:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888078#M350886</guid>
      <dc:creator>Eileen1496</dc:creator>
      <dc:date>2023-08-06T21:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when using order by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888079#M350887</link>
      <description>&lt;P&gt;Thank you, it indeed solves the problem!&lt;/P&gt;</description>
      <pubDate>Sun, 06 Aug 2023 21:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-when-using-order-by/m-p/888079#M350887</guid>
      <dc:creator>Eileen1496</dc:creator>
      <dc:date>2023-08-06T21:42:01Z</dc:date>
    </item>
  </channel>
</rss>

