<?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: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563537#M17311</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276546"&gt;@KSAS56&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, SSIS is SQL Server Integration Service, it's an ETL tool that can store all the SQL stored procedures and can do extra transformations (such as split, merge, fuzzy look up, etc) and can be automated to run all the configured jobs based on your schedule. I didn't use PROC APPEND. I was just using simple create table and insert statement in SQL server.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So instead of using SAS code to connect to the SQL server and PUSH your data into the database you are using a process on the SQL server to PULL data from SAS via some type of connection?&amp;nbsp; What type of connection are your using?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It now sounds like your question is why didn't that process recognize that the variable had a date type format attached to it and automatically convert the values.&amp;nbsp; I would recommend like others have to try loading from a SAS dataset that has a variable with DATETIME values instead of a DATE values and see if that gets converted properly.&amp;nbsp; You can use the DHMS() function to convert.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datetimevar = MHMS(datevar,0,0,0) ;
format datetimevar datetime20.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Jun 2019 14:43:03 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-06-04T14:43:03Z</dc:date>
    <item>
      <title>Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563387#M17293</link>
      <description>&lt;P&gt;I was able to load a SAS dataset into SQL server using SSIS via OLE DB provider. However the Date column's format in SAS is YYMMDDN8. (Informat: 8.), which shows: 20141209 (for example in FSVIEW), when I load it to a staging table in SQL Server with the column type as DATE, it shows 1954-12-08. (If I export to a txt and load into a staging varchar table and then final table with DATE as date type, the date will be correct, but I would like to save a step and go directly from SAS to SQL Server). Anyone has a solution to this? Thanks!!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 20:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563387#M17293</guid>
      <dc:creator>KSAS56</dc:creator>
      <dc:date>2019-06-03T20:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563394#M17294</link>
      <description>&lt;P&gt;Most likely the date columns you are trying to load are datetime columns. Try creating a datetime in SAS with a format of datetime22.2. This is what we do when loading SQL Server tables.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 21:15:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563394#M17294</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-06-03T21:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563397#M17295</link>
      <description>&lt;P&gt;What is the version of the SQL Server ? Have you tried loading with the SAS/Access to SQL Server ( Needs License)&amp;nbsp; or ODBC ?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 21:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563397#M17295</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2019-06-03T21:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563399#M17296</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276546"&gt;@KSAS56&lt;/a&gt; reminder that SAS stores dates in a numeric value. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS dates and SQL server starting dates are not the same so you have to force SQL server to understand what the correct date is for the value you are passing.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 22:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563399#M17296</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-06-03T22:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563402#M17298</link>
      <description>&lt;P&gt;What is SSIS?&lt;/P&gt;
&lt;P&gt;Show the code you used to load the data in the database.&lt;/P&gt;
&lt;P&gt;Did you just use PROC APPEND?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname mydb .... ;
proc append base=mydb.mytable data=mysastable;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Jun 2019 22:13:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563402#M17298</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-03T22:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563531#M17307</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;, Thanks for your&amp;nbsp;suggestion, however when&amp;nbsp;I tried to create &lt;STRONG&gt;format my_dt datetime22.2, &lt;/STRONG&gt;all of the original dates such as:&lt;BR /&gt;20141209&lt;/P&gt;&lt;P&gt;20141121&lt;/P&gt;&lt;P&gt;20150121&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;turn out to be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;01JAN1960:05:34:26.00&lt;/P&gt;&lt;P&gt;01JAN1960:05:34:08.00&lt;/P&gt;&lt;P&gt;01JAN1960:05:35:09.00&lt;/P&gt;&lt;P&gt;So looks like the original columns are date columns, when format using datetime, SAS&amp;nbsp;thinks they are only minutes apart within the same date. One solution that I thought of after your&amp;nbsp;suggestion is: instead of originally thinking I have to&amp;nbsp;export to a TXT in order to maintain the correct date. I tested to just do PUT(my_dt, yymmddn8.) and leave the date column as text and that will actually solve my problem. So instead of TXT file, just a&amp;nbsp;few TXT columns and let SSIS do the transformation. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 14:20:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563531#M17307</guid>
      <dc:creator>KSAS56</dc:creator>
      <dc:date>2019-06-04T14:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563532#M17308</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223452"&gt;@r_behata&lt;/a&gt;, SQL Server is v18.0(2019). Yes, we thought about using the ODBC, and since that is not free, we thought we would try the free ole db provider first.</description>
      <pubDate>Tue, 04 Jun 2019 14:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563532#M17308</guid>
      <dc:creator>KSAS56</dc:creator>
      <dc:date>2019-06-04T14:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563534#M17309</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/122002"&gt;@VDD&lt;/a&gt;&amp;nbsp;, Thanks for your advice! I understand the starting dates aren't the same. SAS is 1960 Jan 1st, do you know what date is SQL server's start date. I used a date calc app to check, the differences between the 20141209 and 1954-12-08 is 21916 days. If I put below is my sql code:&lt;BR /&gt;DATEADD(day, 21916, my_dt) then all the dates are calculated correctly.&lt;/P&gt;&lt;P&gt;But I am still trying to eliminate extra coding and especially if I miss a couple columns then the job won't run.&lt;/P&gt;&lt;P&gt;But thanks again for your help!!! Greatly appreciate it.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 14:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563534#M17309</guid>
      <dc:creator>KSAS56</dc:creator>
      <dc:date>2019-06-04T14:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563535#M17310</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, SSIS is SQL Server Integration Service, it's an ETL tool that can store all the SQL stored procedures and can do extra transformations (such as split, merge, fuzzy look up, etc) and can be automated to run all the configured jobs based on your schedule. I didn't use PROC APPEND. I was just using simple create table and insert statement in SQL server.</description>
      <pubDate>Tue, 04 Jun 2019 14:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563535#M17310</guid>
      <dc:creator>KSAS56</dc:creator>
      <dc:date>2019-06-04T14:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563537#M17311</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276546"&gt;@KSAS56&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, SSIS is SQL Server Integration Service, it's an ETL tool that can store all the SQL stored procedures and can do extra transformations (such as split, merge, fuzzy look up, etc) and can be automated to run all the configured jobs based on your schedule. I didn't use PROC APPEND. I was just using simple create table and insert statement in SQL server.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So instead of using SAS code to connect to the SQL server and PUSH your data into the database you are using a process on the SQL server to PULL data from SAS via some type of connection?&amp;nbsp; What type of connection are your using?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It now sounds like your question is why didn't that process recognize that the variable had a date type format attached to it and automatically convert the values.&amp;nbsp; I would recommend like others have to try loading from a SAS dataset that has a variable with DATETIME values instead of a DATE values and see if that gets converted properly.&amp;nbsp; You can use the DHMS() function to convert.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;datetimevar = MHMS(datevar,0,0,0) ;
format datetimevar datetime20.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jun 2019 14:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563537#M17311</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-04T14:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563540#M17312</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276546"&gt;@KSAS56&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I have this right, you are driving this process from SSIS by connecting to SAS via a SAS OLE DB provider?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is the case, I think you may have to create a SAS Data step view that converts the SAS date into something that SSIS can understand. This will enable the process to happen in one-fell-swoop; you shouldn't have to load the data into a temporary table then massage it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the other hand, it is much easier to do this with SAS/ACCESS Interface to Microsoft SQL Server or SAS/ACCESS Interface to ODBC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best wishes,&lt;BR /&gt;Jeff&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 14:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563540#M17312</guid>
      <dc:creator>JBailey</dc:creator>
      <dc:date>2019-06-04T14:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563551#M17315</link>
      <description>&lt;P&gt;this issue is a Microsoft problem.&amp;nbsp; Use SAS to do what it can do its easier than using MS. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 15:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563551#M17315</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-06-04T15:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563560#M17316</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;, yes. We are doing exactly as you mentioned. "Push" require SAS/Access ODBC driver (license involved, and we will be able to do soon); "Pull" free download using OLE DB Provider (latest 9.4 version) and I have tried the DHMS(my_dt, 0,0,0) function you mentioned and it does produce the right output, I will test next in the SQL Server and see if it achieve what I am looking for, thanks so much!</description>
      <pubDate>Tue, 04 Jun 2019 16:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563560#M17316</guid>
      <dc:creator>KSAS56</dc:creator>
      <dc:date>2019-06-04T16:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563562#M17317</link>
      <description>Thank you for your advices. I will try without the temp table and see (I think the process I ended up with temp table was b/c TXT format was what I was first testing and I just inherit this process when I have a new SAS data source. Also we will be getting the license to do the ODBC way soon ($$ commitment).</description>
      <pubDate>Tue, 04 Jun 2019 16:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563562#M17317</guid>
      <dc:creator>KSAS56</dc:creator>
      <dc:date>2019-06-04T16:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue when loading SAS into SQL Server using SSIS via OLE DB provider</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563690#M17318</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/276546"&gt;@KSAS56&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it should work with a correct date format, so you don't need to cope with the different starting points in SQL and SAS (1900 vs 1960).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But remember that you cannot turn a SAS date into a SAS datetime with a format, because a SAS date value has dates as time unit,&amp;nbsp; while a SAS datetime value has seconds as unit. So the number of days is changed to a number of seconds, when you use a datetime format on a date value, as this example shows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;189  data _null_;
190      date = '09dec2014'd;
191      put date datetime22.2;
192
193      date = date*24*3600;
194      put date datetime22.2;
195  run;

 01JAN1960:05:34:26.00
 09DEC2014:00:00:00.00
&lt;/PRE&gt;
&lt;P&gt;I guess everything works if you convert the number of days to number of seconds.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jun 2019 13:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Date-Format-Issue-when-loading-SAS-into-SQL-Server-using-SSIS/m-p/563690#M17318</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-06-05T13:04:03Z</dc:date>
    </item>
  </channel>
</rss>

