<?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 Date datatype problem while exporting SAS data to SQL Server in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337588#M9970</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to export my SAS data sets to SQL Server.&amp;nbsp;There are 3 date columns in my table. However, I am facing a data type mismatch issue. I&amp;nbsp;have created an&amp;nbsp;empty table with all required columns&amp;nbsp;on SQL Server. The Date columns on SQL Server have the datatype Date. Please find below my code to transfer SAS data to SQL Server:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;Connect&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; odbc(datasrc=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"data"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; user=Writer password=Writer);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;INSERT&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;INTO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SQL.Database&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; * &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SAS.Database&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ID &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IS&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;NOT&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;NULL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;disconnect&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; odbc;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find code I used on SQL server to create blank table (there are more columns than these three):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; database&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;START_DATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Date&lt;/FONT&gt;&lt;FONT color="#808080" face="Consolas" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;END_DATE &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Date&lt;/FONT&gt;&lt;FONT color="#808080" face="Consolas" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;REPORT_DATE &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Date&lt;/FONT&gt;&lt;FONT color="#808080" face="Consolas" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The format and informat of&amp;nbsp;SAS Date columns&amp;nbsp;is MMDYY10.&amp;nbsp;How do I move data from SAS Date columns to the three Date columns on SQL Server?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2017 21:12:52 GMT</pubDate>
    <dc:creator>akhilesh_joshi</dc:creator>
    <dc:date>2017-03-02T21:12:52Z</dc:date>
    <item>
      <title>Date datatype problem while exporting SAS data to SQL Server</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337588#M9970</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to export my SAS data sets to SQL Server.&amp;nbsp;There are 3 date columns in my table. However, I am facing a data type mismatch issue. I&amp;nbsp;have created an&amp;nbsp;empty table with all required columns&amp;nbsp;on SQL Server. The Date columns on SQL Server have the datatype Date. Please find below my code to transfer SAS data to SQL Server:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;Connect&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;to&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; odbc(datasrc=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"data"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; user=Writer password=Writer);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;INSERT&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;INTO&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SQL.Database&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; * &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; SAS.Database&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;WHERE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ID &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;IS&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;NOT&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;NULL&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;disconnect&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; odbc;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;Quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find code I used on SQL server to create blank table (there are more columns than these three):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; database&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;START_DATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Date&lt;/FONT&gt;&lt;FONT color="#808080" face="Consolas" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;END_DATE &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Date&lt;/FONT&gt;&lt;FONT color="#808080" face="Consolas" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;REPORT_DATE &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Consolas" size="2"&gt;Date&lt;/FONT&gt;&lt;FONT color="#808080" face="Consolas" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The format and informat of&amp;nbsp;SAS Date columns&amp;nbsp;is MMDYY10.&amp;nbsp;How do I move data from SAS Date columns to the three Date columns on SQL Server?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 21:12:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337588#M9970</guid>
      <dc:creator>akhilesh_joshi</dc:creator>
      <dc:date>2017-03-02T21:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Date datatype problem while exporting SAS data to SQL Server</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337601#M9971</link>
      <description>&lt;P&gt;I'm assuming you've already searched and tried the standard solutions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what happens if you use Date9 or a datetime type/format instead?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 21:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337601#M9971</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-02T21:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Date datatype problem while exporting SAS data to SQL Server</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337603#M9972</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SAS dataset already has MMDDYY10. format. How do I convert it to Date9. or a datetime format?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 21:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337603#M9972</guid>
      <dc:creator>akhilesh_joshi</dc:creator>
      <dc:date>2017-03-02T21:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Date datatype problem while exporting SAS data to SQL Server</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337612#M9973</link>
      <description>&lt;P&gt;Apply a format...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That code you showed wouldn't work, because when you use SQL pass through you don't have access to your SAS Database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Format variable_name date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 21:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337612#M9973</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-02T21:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Date datatype problem while exporting SAS data to SQL Server</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337617#M9974</link>
      <description>&lt;P&gt;Thanks Reeza. I would definitely give it a try and let you know!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 21:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337617#M9974</guid>
      <dc:creator>akhilesh_joshi</dc:creator>
      <dc:date>2017-03-02T21:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Date datatype problem while exporting SAS data to SQL Server</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337722#M9975</link>
      <description>&lt;P&gt;Here's the documentation explaining the default data type translations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0h4i25zq3t58en1lgr8jjx1rads.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0h4i25zq3t58en1lgr8jjx1rads.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the mismatch you are getting?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 06:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-datatype-problem-while-exporting-SAS-data-to-SQL-Server/m-p/337722#M9975</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-03-03T06:40:21Z</dc:date>
    </item>
  </channel>
</rss>

