<?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 conversion of date from character to date format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Incorrect-conversion-of-date-from-character-to-date-format/m-p/596790#M16023</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293553"&gt;@PernilleBaekke&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dates are stored as numeric values in SAS. So you first need to convert your character value in a numeric one using the input() function and the correct informat for reading the value (ddmmyy10.).&lt;/P&gt;
&lt;P&gt;Then you can apply a date format to your new variable (date9. for example).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this help!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input date_old $ 1-10;
	cards;
11-06-2013
;
run;

data want;
	set have;
	format date_new date9.;
	date_new = input(date_old, ddmmyy10.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 16 Oct 2019 09:30:00 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2019-10-16T09:30:00Z</dc:date>
    <item>
      <title>Incorrect conversion of date from character to date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Incorrect-conversion-of-date-from-character-to-date-format/m-p/596785#M16020</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to convert a date from character to date format in SAS Enterprise Guide 7.1. I've used the format function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1; 
          date_new=date_old; 
          format date_new date9.; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;however, when I do so, my date is changed from&amp;nbsp;11-06-2013 to&amp;nbsp;06-11-2013, which is not the same date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 11-06-2013 = 11Jun2013 (correct date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; 06-11-2013 = 06Nov2013 (wrong date)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you can help me. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 09:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Incorrect-conversion-of-date-from-character-to-date-format/m-p/596785#M16020</guid>
      <dc:creator>PernilleBaekke</dc:creator>
      <dc:date>2019-10-16T09:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Date character to date format conversion</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Incorrect-conversion-of-date-from-character-to-date-format/m-p/596789#M16022</link>
      <description>&lt;P&gt;The format only changes the way a value is &lt;EM&gt;displayed&lt;/EM&gt;, it does not &lt;EM&gt;change the contents&lt;/EM&gt;. So if a date with format date9. displays as 06NOV2013, that is the value stored, period. You might have a misunderstanding of the display format of variable date_old (ddmmyyd10. vs. mmddyyd10.)&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 09:27:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Incorrect-conversion-of-date-from-character-to-date-format/m-p/596789#M16022</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-16T09:27:11Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect conversion of date from character to date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Incorrect-conversion-of-date-from-character-to-date-format/m-p/596790#M16023</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293553"&gt;@PernilleBaekke&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dates are stored as numeric values in SAS. So you first need to convert your character value in a numeric one using the input() function and the correct informat for reading the value (ddmmyy10.).&lt;/P&gt;
&lt;P&gt;Then you can apply a date format to your new variable (date9. for example).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this help!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input date_old $ 1-10;
	cards;
11-06-2013
;
run;

data want;
	set have;
	format date_new date9.;
	date_new = input(date_old, ddmmyy10.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 09:30:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Incorrect-conversion-of-date-from-character-to-date-format/m-p/596790#M16023</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-10-16T09:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect conversion of date from character to date format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Incorrect-conversion-of-date-from-character-to-date-format/m-p/596949#M16049</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/293553"&gt;@PernilleBaekke&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to convert a date from character to date format in SAS Enterprise Guide 7.1. I've used the format function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1; 
          date_new=date_old; 
          format date_new date9.; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;however, when I do so, my date is changed from&amp;nbsp;11-06-2013 to&amp;nbsp;06-11-2013, which is not the same date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; 11-06-2013 = 11Jun2013 (correct date)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; 06-11-2013 = 06Nov2013 (wrong date)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you can help me. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So what should the "correct" date be for 06-11-2013? I believe you are implying without stating it that you also expect the second to be treated as 11Jun2013.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you read both character values then SAS expects &lt;STRONG&gt;all&lt;/STRONG&gt; of the values to be in either month-day-year or day-month-year order. The default depends on your national language settings as to whether month or day is the default for the&amp;nbsp;first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not show the code you used to convert a character to date. But with your given example I do not see how &lt;STRONG&gt;you&lt;/STRONG&gt; know the second is "incorrect". If there is another variable that indicates some information then you can test that variable(or variables) and conditionally execute different INPUT statements or set a variable to the appropriate informat and use inputn.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 15:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Incorrect-conversion-of-date-from-character-to-date-format/m-p/596949#M16049</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-16T15:26:30Z</dc:date>
    </item>
  </channel>
</rss>

