<?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: Incorrect Date in the Dataset (Reversing Date and Months) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352965#M82343</link>
    <description>&lt;P&gt;Is that date variable a SAS date value or character?&lt;/P&gt;</description>
    <pubDate>Mon, 24 Apr 2017 18:19:47 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-04-24T18:19:47Z</dc:date>
    <item>
      <title>Incorrect Date in the Dataset (Reversing Date and Months)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352406#M82135</link>
      <description>&lt;P&gt;Hi SAS Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been given a dataset and the dates were incorrectly imported (but I don't have the raw file). So, at the moment, the dataset has the following entries:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;01 JAN 2010&lt;/P&gt;
&lt;P&gt;01 FEB 2010 (which supposed to be 02 JAN 2010)&lt;/P&gt;
&lt;P&gt;01 MAR 2010 (which supposed to be 03 JAN 2010)&lt;/P&gt;
&lt;P&gt;01 APR 2010&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;01 DEC 2010&lt;/P&gt;
&lt;P&gt;13 JAN 2010&lt;/P&gt;
&lt;P&gt;14 JAN 2010&lt;/P&gt;
&lt;P&gt;15 JAN 2010&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In short, the first 12 dates are incorrect as the dates and months are swapped. However, from date 13 onwards, it is correct and reads well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, does anyone have a solution to combat this problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;BR /&gt;&lt;BR /&gt;David&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 07:39:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352406#M82135</guid>
      <dc:creator>DavidLie</dc:creator>
      <dc:date>2017-04-22T07:39:57Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Date in the Dataset (Reversing Date and Months)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352409#M82137</link>
      <description>&lt;P&gt;I would like a better sample to know what's in there in your dataset. Anyway, see if this helps:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;retain _date;&lt;/P&gt;&lt;P&gt;if _n_=&lt;STRONG&gt;1&lt;/STRONG&gt; then _date=date;&lt;/P&gt;&lt;P&gt;if _n_&amp;gt;&lt;STRONG&gt;1&lt;/STRONG&gt; then do;&lt;/P&gt;&lt;P&gt;if date ne _date+&lt;STRONG&gt;1&lt;/STRONG&gt; then date=_date+&lt;STRONG&gt;1&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;_date=date;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;format _date&amp;nbsp; date9.;&lt;/P&gt;&lt;P&gt;drop _date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naveen Srinivasan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 09:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352409#M82137</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-04-22T09:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Date in the Dataset (Reversing Date and Months)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352413#M82139</link>
      <description>&lt;PRE&gt;
It seems you reverse the month and day.

data _null_;
d1='01feb2010'd;
d2=mdy(day(d1),month(d1),year(d1));
put d1= date9. d2= date9.;
run;

&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Apr 2017 10:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352413#M82139</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-04-22T10:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Date in the Dataset (Reversing Date and Months)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352449#M82154</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data better ;
set have ;
 if day( date) &amp;lt;= 12 then date = mdy( day( date), month( date), year( date) ) ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This would implement the general fix where informat anydtdte. has used the wrong default order&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 16:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352449#M82154</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-04-22T16:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Date in the Dataset (Reversing Date and Months)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352454#M82156</link>
      <description>&lt;P&gt;If your dates are already SAS dates, then others have already provided the solution you're looking for. However, the way you showed them, they look like they are in a character field. If so, I'd suggest trying something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  informat date $11.;
  input date &amp;amp;;
  cards;
01 JAN 2010
01 FEB 2010
01 MAR 2010
01 APR 2010
01 MAY 2010
01 JUN 2010
01 JUL 2010
01 AUG 2010
01 SEP 2010
01 OCT 2010
01 NOV 2010
01 DEC 2010
13 JAN 2010
14 JAN 2010
;

data want (drop=_:);
  format date date9.;
  set have (rename=(date=_date));
  date=input(_date,anydtdte11.);
  if _n_ le 12 then date=mdy(day(date),month(date),year(date));
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 17:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352454#M82156</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-22T17:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect Date in the Dataset (Reversing Date and Months)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352965#M82343</link>
      <description>&lt;P&gt;Is that date variable a SAS date value or character?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2017 18:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Incorrect-Date-in-the-Dataset-Reversing-Date-and-Months/m-p/352965#M82343</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-24T18:19:47Z</dc:date>
    </item>
  </channel>
</rss>

