<?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: Change Field Data Type from Numeric to Character in PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201316#M266828</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you are using pass through functionality you can put the transformation into either the SAS part of the statement or the Oracle part of the statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're going to place the transformation into the oracle statement, use oracle language, for instance TO_CHAR .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Jun 2015 11:42:00 GMT</pubDate>
    <dc:creator>Keith0001</dc:creator>
    <dc:date>2015-06-10T11:42:00Z</dc:date>
    <item>
      <title>Change Field Data Type from Numeric to Character in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201313#M266825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to change a data type for a field (field1) that I am querying from numeric to character. Here is the code that runs and provides the field back as a numeric data type using PROC SQL. I have been able to convert the number to a character using the Data statement along with the put function but can thus be accomplished in the PROC SQL statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;connect to oracle as example(user=***** pw=***** path=abcd.xxxxx.com);&lt;/P&gt;&lt;P&gt;create table work.data as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from connection to example&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;select field1, field2, from example.Address&lt;/P&gt;&lt;P&gt;where Address_Type = 'PRIMARY'&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is what I have tried but get the following error message&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;connect to oracle as example (user=xxxxx pw=xxxx path=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;abcd.xxxxx.com&lt;/SPAN&gt;.com);&lt;/P&gt;&lt;P&gt;create table work.data as&lt;/P&gt;&lt;P&gt;select *&lt;/P&gt;&lt;P&gt;from connection to example&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;select field1 as put(field1, $15.), field2 from example.Agency_Address&lt;/P&gt;&lt;P&gt;where Address_Type = 'PRIMARY'&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: ORACLE prepare error: ORA-00923: FROM keyword not found where expected. SQL statement: select field1 as &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left(put(field1, $15.)), field2 from Example.Agency_Address where Address_Type = 'PRIMARY'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for your time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 17:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201313#M266825</guid>
      <dc:creator>madamimadam</dc:creator>
      <dc:date>2015-06-09T17:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Change Field Data Type from Numeric to Character in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201314#M266826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The put function you are using will work the same way if you use proc sql;, what you are showing here is passing through to oracle, you will need to use a function that works with the database you are connecting too, not something that will work within SAS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 18:10:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201314#M266826</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-06-09T18:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Change Field Data Type from Numeric to Character in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201315#M266827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The PUT function always returns a character string. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second parameter (in this case $15.) must use a dollar sign when the first parameter is character, and must omit the dollar sign when the first parameter is numeric.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you're making a numeric to character conversion, try removing the dollar sign:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put(field1, 15.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jun 2015 18:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201315#M266827</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-06-09T18:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Change Field Data Type from Numeric to Character in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201316#M266828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since you are using pass through functionality you can put the transformation into either the SAS part of the statement or the Oracle part of the statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you're going to place the transformation into the oracle statement, use oracle language, for instance TO_CHAR .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 11:42:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201316#M266828</guid>
      <dc:creator>Keith0001</dc:creator>
      <dc:date>2015-06-10T11:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Change Field Data Type from Numeric to Character in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201317#M266829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do the conversion in SAS:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;connect to oracle as example (user=xxxxx pw=xxxx path=&lt;SPAN style="font-size: 13.3333330154419px;"&gt;abcd.xxxxx.com&lt;/SPAN&gt;.com);&lt;/P&gt;&lt;P&gt;create table work.data as&lt;/P&gt;&lt;P&gt;select put(field1,15.) as field1, field2&lt;/P&gt;&lt;P&gt;from connection to example&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;select field1, field2 from example.Agency_Address&lt;/P&gt;&lt;P&gt;where Address_Type = 'PRIMARY'&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also note the reverse ordering of the select ... as ... (function first, name second)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 11:58:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201317#M266829</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-06-10T11:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: Change Field Data Type from Numeric to Character in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201318#M266830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The above posters have given you the answer here, in pass-through code the syntax must match the Database syntax requirements.&amp;nbsp; In SAS SQL you can use SAS syntax rules.&amp;nbsp; Maybe if you want to combine the two (and of course, avoiding the * syntax totally, because that would just be guessing!):&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;proc sql;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; connect to oracle as example (user=xxxxx pw=xxxx path=&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 13.3333330154419px; font-family: inherit;"&gt;abcd.xxxxx.com&lt;/SPAN&gt;.com);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table work.data as&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;/* This part is processed by SAS and must conform to SAS syntax */&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put(FIELD1,best.) as FIELD1,&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FIELD2 as FIELD2&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from connection to example&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;/* This part is passed to the database and must conform to the database syntax */&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select field1, field2 from example.Agency_Address&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where Address_Type = 'PRIMARY'&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jun 2015 12:02:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-Field-Data-Type-from-Numeric-to-Character-in-PROC-SQL/m-p/201318#M266830</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-06-10T12:02:28Z</dc:date>
    </item>
  </channel>
</rss>

