<?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 and ordering alphanumeric in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81060#M23387</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LinusH, glad that even though none of you got the "real" question quite right,&lt;BR /&gt;the problem is understood. Sorting of alpha numeric characters (see title)&lt;/P&gt;&lt;P&gt;If there is no ansi sql standard that I can use with my proc sql,&lt;BR /&gt;and believe me, I looked a lot through Oracle documentation (but one can never be sure to cover it all -so I asked here), then I was hoping there is a SAS one. Various SAS people I have asked in the meantime suggested to fill the single digit numbers&lt;BR /&gt;(rpad in oracle -but does not work for me *ERROR: Function RPAD could not be located.*)&lt;BR /&gt;with 0 and try the sorting again. - I think this comes close to what&lt;BR /&gt;Quentin suggested with&amp;nbsp; order by input(var,8.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Jan 2013 11:50:33 GMT</pubDate>
    <dc:creator>metalray</dc:creator>
    <dc:date>2013-01-24T11:50:33Z</dc:date>
    <item>
      <title>PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81048#M23375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;We use an Oracle 10g database and I need to order an alphanumeric columns in my PROC SQL.&lt;/P&gt;&lt;P&gt;Now, SAS does not understand Oracle specific functions like to_number, lpad, translate, regex so I&lt;/P&gt;&lt;P&gt;wonder if someone knows a standard sql (ansi) way to sort such a column?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jan 2013 16:43:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81048#M23375</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2013-01-21T16:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81049#M23376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It might be most efficient to run the query as a pass-through query to Oracle.&amp;nbsp; That way Oracle would do the heavy lifting, and would return the results to SAS.&amp;nbsp; And you could use Oracle-specific functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But sounds like you are using SAS to run the query.&amp;nbsp; In which case, you will need to use SAS functions in your query rather than oracle functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is an example of using the INPUT function on a character variable to order by numeric values.&amp;nbsp; Feel free to post more specifics if you need help with other SASsy conversions (handling date strings, etc).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data a;
&amp;nbsp; input var $;
&amp;nbsp; cards;
5
10
15
20
;
run;

proc sql;
&amp;nbsp; select *
&amp;nbsp;&amp;nbsp;&amp;nbsp; from a
&amp;nbsp;&amp;nbsp;&amp;nbsp; order by var
&amp;nbsp; ;
&amp;nbsp; select *
&amp;nbsp;&amp;nbsp;&amp;nbsp; from a
&amp;nbsp;&amp;nbsp;&amp;nbsp; order by input(var,8.)
&amp;nbsp; ;
quit;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jan 2013 18:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81049#M23376</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-01-21T18:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81050#M23377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you explain a bit more what type of data you're trying to sort and how?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within a SQL step or is proc sort an option?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jan 2013 18:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81050#M23377</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-21T18:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81051#M23378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Quentin.&lt;/P&gt;&lt;P&gt;I am using PROC SQL (in a SAS STP) and sql pass through, that is right but the SAS driver's&lt;BR /&gt;for Oracle only allow me to use ANSI standard sql function not Oracle specific functions &lt;BR /&gt;like decode or to_date, etc.&lt;/P&gt;&lt;P&gt;Is there no ANSI standard SQL I can use for ordering alphanumeric data?&lt;BR /&gt;Too bad.&lt;/P&gt;&lt;P&gt;alphanumeric data, stuff like:&lt;BR /&gt;1&lt;BR /&gt;3&lt;BR /&gt;65&lt;BR /&gt;42&lt;BR /&gt;EA&lt;BR /&gt;UD&lt;BR /&gt;EB&lt;/P&gt;&lt;P&gt;@Reeza, PROC SQL, sorting a column that contains alphanumeric data&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 10:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81051#M23378</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2013-01-22T10:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81052#M23379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you show a little bit of your SQL code?&amp;nbsp; If it's an explicit pass-through query, then I'm pretty confident that you can use Oracle specific functions (I've certainly done it in the past).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does your code look something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;proc sql;
&amp;nbsp; connect to oracle (user=... );
&amp;nbsp; select * from connection to oracle
&amp;nbsp;&amp;nbsp;&amp;nbsp; (
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from MyFavoriteOracleTable
&amp;nbsp;&amp;nbsp;&amp;nbsp; );
 ...
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it does, then the nested query should be executing on oracle, and should allow oracle specific functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 10:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81052#M23379</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-01-22T10:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81053#M23380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you like to influence the sort order in SAS, you could take a look at SORTSEQ=, TRANTAB and Collating Sequence options in SAS. I'm pretty sure you could accomplish what you need using these in the right way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Functions: SAS is able to translate some SAS functions to corresponding Oracle functions, see online doc for SAS/ACCESS for more details. To analyze what parts of the query that implicitly be sent to Oracle, use the SASTARCE global options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But again, if you really need to a pass-thru, maybe for performance issues, you are most safe writing an explicit SQL pass-thru.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 11:41:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81053#M23380</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-01-22T11:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81054#M23381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Helllo Quentin,&lt;/P&gt;&lt;P&gt;Thanks for your reply. Unfortunately I can't provide a more extensive example but why&lt;BR /&gt;is it needed for sorting?&lt;/P&gt;&lt;P&gt;Your suggested "order by input(var,8.)" worked! Just that the letter sorting like&lt;BR /&gt;EA&lt;BR /&gt;JK&lt;BR /&gt;QO&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;comes before the numbers, and I need it the other way around.&lt;/P&gt;&lt;P&gt;Yes, my Oracle query looks like yours.&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp; connect to oracle (user=... );&lt;BR /&gt;&amp;nbsp; select * from connection to oracle&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from MyFavoriteOracleTable&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;BR /&gt; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;BR /&gt;but...Oracle specific functions like DECODE do not work. (ERROR: Function DECODE could not be located.)&lt;/P&gt;&lt;P&gt;@LinusH,&lt;BR /&gt;Thanks for your input. I need to use SQL pass-through. no way around it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 15:12:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81054#M23381</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2013-01-22T15:12:26Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81055#M23382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; connect to oracle (user=... );&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from connection to oracle&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select *&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from MyFavoriteOracleTable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/P&gt;&lt;P&gt; ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your Oracle SQL functions need to go in the second select * area, e.g&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; connect to oracle (user=... );&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from connection to oracle&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select decode() , to_char()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from MyFavoriteOracleTable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jan 2013 15:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81055#M23382</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-22T15:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81056#M23383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reeza. I know that &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt; but that does not solve the problem. How do I sort my alpha numeric data in the column. Numbers first, then the letter combinations.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jan 2013 08:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81056#M23383</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2013-01-23T08:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81057#M23384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm confused, are you asking how to do this in Oracle now?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Assuming you know how to do what you want in Oracle, I would suggest you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Send a (simple) example of the query you can run in Oracle to do what you want.&lt;/P&gt;&lt;P&gt;2. Send the SAS log you get from running that query inside of an explicit pass-through block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm still stuck on that if you have working code in Oracle, that code should work inside the pass-through block. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But if you don't know how to do want in Oracle, then I missed the point of the original question...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jan 2013 17:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81057#M23384</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-01-23T17:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81058#M23385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did ask if&amp;nbsp; someone knows a standard ansi sql way of doing it in oracle (proc sql pass through) since this does not seem to exist. the error I get I posted. I am happy&lt;/P&gt;&lt;P&gt;to learn about a way how to do it in sas. what I tried yesterday , after the proc sql. a proc sort.&lt;/P&gt;&lt;P&gt;but the proc sort did not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=&amp;nbsp; t_stp_temp noduprecs;&lt;/P&gt;&lt;P&gt;by myIDnumber ;&lt;/P&gt;&lt;P&gt;run; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 08:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81058#M23385</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2013-01-24T08:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81059#M23386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm also confused of what the &lt;EM&gt;real&lt;/EM&gt; question is.&lt;/P&gt;&lt;P&gt;If the main issue is if there is support in ANSI 92 SQL for dealing with your specific sorting requirement - no, I don't think so.&lt;/P&gt;&lt;P&gt;So, next issue, to solve this in&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Oracle specific SQL, using SAS SQL pass-thru: you need to search for Oracle documentation/go to an Oracle forum&lt;/LI&gt;&lt;LI&gt;Using SAS SQL: explore the possibilities to setting custom sequences, see my earlier post.&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 10:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81059#M23386</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-01-24T10:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL and ordering alphanumeric</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81060#M23387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;LinusH, glad that even though none of you got the "real" question quite right,&lt;BR /&gt;the problem is understood. Sorting of alpha numeric characters (see title)&lt;/P&gt;&lt;P&gt;If there is no ansi sql standard that I can use with my proc sql,&lt;BR /&gt;and believe me, I looked a lot through Oracle documentation (but one can never be sure to cover it all -so I asked here), then I was hoping there is a SAS one. Various SAS people I have asked in the meantime suggested to fill the single digit numbers&lt;BR /&gt;(rpad in oracle -but does not work for me *ERROR: Function RPAD could not be located.*)&lt;BR /&gt;with 0 and try the sorting again. - I think this comes close to what&lt;BR /&gt;Quentin suggested with&amp;nbsp; order by input(var,8.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jan 2013 11:50:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-and-ordering-alphanumeric/m-p/81060#M23387</guid>
      <dc:creator>metalray</dc:creator>
      <dc:date>2013-01-24T11:50:33Z</dc:date>
    </item>
  </channel>
</rss>

