<?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: Help - Proc SQL is changing the formatting of some date variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/337578#M76679</link>
    <description>&lt;P&gt;""date" in the base dataset gets changed to datetime20"&amp;nbsp; Which is the base dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you give us some sample data from all tables you&amp;nbsp;are referencing so we can see what might be going on?&lt;/P&gt;</description>
    <pubDate>Thu, 02 Mar 2017 21:03:16 GMT</pubDate>
    <dc:creator>nehalsanghvi</dc:creator>
    <dc:date>2017-03-02T21:03:16Z</dc:date>
    <item>
      <title>Help - Proc SQL is changing the formatting of some date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/337566#M76673</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I have a large administrative school dataset where I want to delete and replace the last 30 days of data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One varable called "date" which is date9 format (DDMONYYYY) is giving me some havoc during this process. For some reason, "date" in the base dataset gets changed to datetime20 format during the below proc sql command, and then the data for the "date" variable in the appending 30 days dataset is entered improperly because the two date formats no longer match.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I really don't know why this would be occuring.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have double checked all the date formating up to the following SAS syntax, and the date format is Date9. in all tables up to this point. After this syntax is run, it becomes datetime20 and all dates from the last 30 days are entered as "01JAN1960:05:47:52".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
            connect to odbc                                                                                                                                                
            (dsn="SCHEMA"
            user=USERNAME
            password=PASSWORD);
                  execute (                                                                                                                                                        
                  delete from "school_rp" WHERE                                                                                                                           
                  event_reported_datetime &amp;gt;= to_date(%BQUOTE('&amp;amp;last30days'),'DDMONYYYY')
                  ) by odbc;                                                                                                                                                  

      INSERT into schema.school_rp                                                                                                                              
      Select * from temp.school_rp_last30;                                                                                                                                 
                                                                                                                                                                       
      disconnect from odbc;                                                                                                                                            
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any ideas on what's happening?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/337566#M76673</guid>
      <dc:creator>Jordan88</dc:creator>
      <dc:date>2017-03-02T20:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help - Proc SQL is changing the formatting of some date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/337578#M76679</link>
      <description>&lt;P&gt;""date" in the base dataset gets changed to datetime20"&amp;nbsp; Which is the base dataset?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you give us some sample data from all tables you&amp;nbsp;are referencing so we can see what might be going on?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 21:03:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/337578#M76679</guid>
      <dc:creator>nehalsanghvi</dc:creator>
      <dc:date>2017-03-02T21:03:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help - Proc SQL is changing the formatting of some date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/337590#M76686</link>
      <description>&lt;P&gt;Although it looks like a date, I suspect SAS interprets most dates from DB as datetime.&lt;/P&gt;
&lt;P&gt;You don't specify what database type you're using, but some only store dates as datetime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would try the following, without any calculation, extract the variable that's 'changing' and see what format SAS see's it in.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or just treat it as a date time and go from there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Mar 2017 21:14:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/337590#M76686</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-02T21:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Help - Proc SQL is changing the formatting of some date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/338503#M77089</link>
      <description>The base dataset is the "school_rp" seen in the syntax. Yes, I will post below with an attachment.</description>
      <pubDate>Mon, 06 Mar 2017 17:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/338503#M77089</guid>
      <dc:creator>Jordan88</dc:creator>
      <dc:date>2017-03-06T17:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help - Proc SQL is changing the formatting of some date variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/338507#M77091</link>
      <description>&lt;P&gt;Ahhh yes, you are absolutely right. Thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is an Oracle database that it is saving it to, and it does say when you write to it that it does not save the SAS variable formatting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So it is saving as a datetime variable, and then appending as a date variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess I'll just format "date" the "last 30 days" dataset as datetime.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 17:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-Proc-SQL-is-changing-the-formatting-of-some-date-variables/m-p/338507#M77091</guid>
      <dc:creator>Jordan88</dc:creator>
      <dc:date>2017-03-06T17:41:19Z</dc:date>
    </item>
  </channel>
</rss>

