<?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 ODBC connection and character dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ODBC-connection-and-character-dates/m-p/113096#M23335</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to pull data from an ODBC connection (SQL Server), and whenever I pull a date variable, it's coming into SAS as character rather than as numeric. Here's the code I'm using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; PROC SQL;&lt;/P&gt;&lt;P&gt;CONNECT TO ODBC(DSN='SQL Server');&lt;/P&gt;&lt;P&gt;CREATE TABLE demogs AS&lt;/P&gt;&lt;P&gt;SELECT *&lt;BR /&gt;FROM CONNECTION TO ODBC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;customer_id,&lt;/P&gt;&lt;P&gt;convert(date,birthdate) as birthdate&lt;/P&gt;&lt;P&gt;&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;The birthdate field comes into SAS as a character variable (e.g., "1986-10-08"). How can I get the imported character date value to be numeric? The reason the "convert" statement is used in the SQL code is that the original date value is in DATETIME, but there is NO time on any of the date values. Thus, I'd prefer to just pull in the month, day, and year and drop the time element (which is always 00:00:00:000) altogether.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sure this is probably a common enough problem, but after searching through the forums (and elsewhere online), I wasn't able to find an issue that touched on this specific ODBC connection problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Oct 2013 16:59:34 GMT</pubDate>
    <dc:creator>newnoise</dc:creator>
    <dc:date>2013-10-15T16:59:34Z</dc:date>
    <item>
      <title>ODBC connection and character dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODBC-connection-and-character-dates/m-p/113096#M23335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to pull data from an ODBC connection (SQL Server), and whenever I pull a date variable, it's coming into SAS as character rather than as numeric. Here's the code I'm using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; PROC SQL;&lt;/P&gt;&lt;P&gt;CONNECT TO ODBC(DSN='SQL Server');&lt;/P&gt;&lt;P&gt;CREATE TABLE demogs AS&lt;/P&gt;&lt;P&gt;SELECT *&lt;BR /&gt;FROM CONNECTION TO ODBC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;customer_id,&lt;/P&gt;&lt;P&gt;convert(date,birthdate) as birthdate&lt;/P&gt;&lt;P&gt;&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;The birthdate field comes into SAS as a character variable (e.g., "1986-10-08"). How can I get the imported character date value to be numeric? The reason the "convert" statement is used in the SQL code is that the original date value is in DATETIME, but there is NO time on any of the date values. Thus, I'd prefer to just pull in the month, day, and year and drop the time element (which is always 00:00:00:000) altogether.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sure this is probably a common enough problem, but after searching through the forums (and elsewhere online), I wasn't able to find an issue that touched on this specific ODBC connection problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Oct 2013 16:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODBC-connection-and-character-dates/m-p/113096#M23335</guid>
      <dc:creator>newnoise</dc:creator>
      <dc:date>2013-10-15T16:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC connection and character dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODBC-connection-and-character-dates/m-p/113097#M23336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just accept as datetime and use sas format DTDATE9.&lt;/P&gt;&lt;P&gt;That hides the time part&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Oct 2013 17:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODBC-connection-and-character-dates/m-p/113097#M23336</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-10-15T17:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: ODBC connection and character dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODBC-connection-and-character-dates/m-p/113098#M23337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks! I figured it was an easy solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Oct 2013 18:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODBC-connection-and-character-dates/m-p/113098#M23337</guid>
      <dc:creator>newnoise</dc:creator>
      <dc:date>2013-10-15T18:36:09Z</dc:date>
    </item>
  </channel>
</rss>

