<?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: SAS Base Date insert into Oracle Date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Base-Date-insert-into-Oracle-Date/m-p/300611#M63504</link>
    <description>Life could be so easy....) &lt;BR /&gt;&lt;BR /&gt;Thank you very much Reeza.&lt;BR /&gt;&lt;BR /&gt;Input(mdupdate, datetime20.) format = datetime20.  --&amp;gt; this was the solution!&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your very fast help! Great work!&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;George</description>
    <pubDate>Sun, 25 Sep 2016 13:07:25 GMT</pubDate>
    <dc:creator>sorosch</dc:creator>
    <dc:date>2016-09-25T13:07:25Z</dc:date>
    <item>
      <title>SAS Base Date insert into Oracle Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Base-Date-insert-into-Oracle-Date/m-p/300608#M63501</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want to insert a SAS Date from a SAS Table into a Oracle Date-column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I searched already in Google and in this forum - but i get always:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Value 7 on the SELECT clause does not match the data type of the corresponding column listed after the INSERT table name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Oracle table looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CREATE TABLE "TEST_TABLE" &lt;BR /&gt;&amp;nbsp;&amp;nbsp; (&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;"REPORT_CREATION" DATE&lt;BR /&gt;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The date-column "mdupdate" in the SAS Table is "alphanumeric 20" and it is shown: "29Jun2016:14:55:56"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One example i tried is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;INSERT INTO &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;ORADB.TEST_TABLE (REPORT_CREATION) &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;SELECT &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put(mdupdate,datetime22.) &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;from &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;SB0520C.REPORTS;&lt;BR /&gt;&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or i tried it with:&lt;/P&gt;
&lt;P&gt;mdupdate format=datetime22.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But i get always an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How must i format the date correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can someone help please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;George&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>Sun, 25 Sep 2016 12:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Base-Date-insert-into-Oracle-Date/m-p/300608#M63501</guid>
      <dc:creator>sorosch</dc:creator>
      <dc:date>2016-09-25T12:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Base Date insert into Oracle Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Base-Date-insert-into-Oracle-Date/m-p/300610#M63503</link>
      <description>&lt;P&gt;SAS has numeric and character variables. It sounds like you have a char variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oracle will want a numeric variable with a datetime format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try input instead of put, which will convert your char variable to a numeric variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Input(mdupdate, datetime20.) format = datetime20.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Sep 2016 12:45:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Base-Date-insert-into-Oracle-Date/m-p/300610#M63503</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-25T12:45:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Base Date insert into Oracle Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Base-Date-insert-into-Oracle-Date/m-p/300611#M63504</link>
      <description>Life could be so easy....) &lt;BR /&gt;&lt;BR /&gt;Thank you very much Reeza.&lt;BR /&gt;&lt;BR /&gt;Input(mdupdate, datetime20.) format = datetime20.  --&amp;gt; this was the solution!&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your very fast help! Great work!&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;George</description>
      <pubDate>Sun, 25 Sep 2016 13:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Base-Date-insert-into-Oracle-Date/m-p/300611#M63504</guid>
      <dc:creator>sorosch</dc:creator>
      <dc:date>2016-09-25T13:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Base Date insert into Oracle Date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Base-Date-insert-into-Oracle-Date/m-p/300612#M63505</link>
      <description>&lt;P&gt;The SAS Access to Oracle Engine communicates with the Oracle client to communicate with your Oracle server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In doing so the Access Engine must know of which data type a SAS variable should become for Oracle. Now standard SAS has only 2 variable types - numeric or character. So for SAS to pass on the correct type to Oracle (Date), SAS needs to know that the SAS variable of type Numeric represents a SAS Date or Datetime. The way SAS gets that is via the Format assigned to the numeric SAS variable - BUT: The SAS variable must remain numeric and not get converted to a string like done in your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF you have already a permanend DATETIME. format assigned to variable "mdupdate" the you can just use it directly as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
    INSERT INTO 
        ORADB.TEST_TABLE (REPORT_CREATION) 
    SELECT 
        mdupdate 
    from 
        SB0520C.REPORTS;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;IF "mdupdate" doesn't have a permanent format applied then something like below should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
    INSERT INTO 
        ORADB.TEST_TABLE (REPORT_CREATION) 
    SELECT 
        mdupdate format=datetime21.
    from 
        SB0520C.REPORTS;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What you also can do, is using data set option "dbtype" - but this should only be necessary in very special situations.&amp;nbsp;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/69039/HTML/default/viewer.htm#p1dqaq7ub1cm1pn1ow3x9qkmkxe8.htm&amp;nbsp;" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/69039/HTML/default/viewer.htm#p1dqaq7ub1cm1pn1ow3x9qkmkxe8.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW: I've made the experience that the SAS Access to Oracle engine doesn't recognize all SAS Date and Datetime formats (=eventually converting the SAS variable to an Oracle column of type numeric). If you want to stay on the save side then use DATE9. and DATETIME21.&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>Sun, 25 Sep 2016 13:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Base-Date-insert-into-Oracle-Date/m-p/300612#M63505</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-09-25T13:08:40Z</dc:date>
    </item>
  </channel>
</rss>

