<?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: Format String with dashes and different formats to date in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Format-String-with-dashes-and-different-formats-to-date/m-p/556406#M74746</link>
    <description>&lt;P&gt;You almost have it. You have to use the MMDDYY10. informat and not the DDMMYY10. Like this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
text_date="03/15/2015";output;
text_date="3/17/2016";output;
run;

data want;
   set have;
   Correct_date = input(text_date,mmddyy10.);
   format Correct_date mmddyy10.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 May 2019 13:02:33 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-05-06T13:02:33Z</dc:date>
    <item>
      <title>Format String with dashes and different formats to date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Format-String-with-dashes-and-different-formats-to-date/m-p/556403#M74745</link>
      <description>&lt;P&gt;Greetings Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this text&amp;nbsp;variable that captures the dates&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1" cellspacing="1" cellpadding="2"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P align="left"&gt;&lt;FONT face="Calibri" size="3"&gt;03/15/2015&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P align="right"&gt;&lt;FONT face="Calibri" size="3"&gt;3/17/2016&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some with leading zeros (for Jan to Sep), and some without the leading zeros. I need to convert it into a date format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried this code:&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Correct_date = input(text_date,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;ddmmyy10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; Correct_date &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;YYMMDD10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;I received this error:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;NOTE: Invalid argument to function INPUT at line 30 column 15.&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 12:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Format-String-with-dashes-and-different-formats-to-date/m-p/556403#M74745</guid>
      <dc:creator>altijani</dc:creator>
      <dc:date>2019-05-06T12:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Format String with dashes and different formats to date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Format-String-with-dashes-and-different-formats-to-date/m-p/556406#M74746</link>
      <description>&lt;P&gt;You almost have it. You have to use the MMDDYY10. informat and not the DDMMYY10. Like this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
text_date="03/15/2015";output;
text_date="3/17/2016";output;
run;

data want;
   set have;
   Correct_date = input(text_date,mmddyy10.);
   format Correct_date mmddyy10.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 13:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Format-String-with-dashes-and-different-formats-to-date/m-p/556406#M74746</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-06T13:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Format String with dashes and different formats to date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Format-String-with-dashes-and-different-formats-to-date/m-p/556414#M74748</link>
      <description>&lt;P&gt;Thank you &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304" target="_self"&gt;&lt;SPAN class="login-bold"&gt;draycut&lt;/SPAN&gt;&lt;/A&gt; for the code. I found where the problem is. I have some dates with month and year, but&amp;nbsp;that have 0 for the day as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;05/0/2015&lt;/P&gt;&lt;P&gt;11/0/2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The converted dates with your code are missings. I&amp;nbsp;need to convert them to the beginning of the month, if the day is 0 as follows:&lt;/P&gt;&lt;P&gt;05/01/2015&lt;/P&gt;&lt;P&gt;11/01/2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how that can be done?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2019 13:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Format-String-with-dashes-and-different-formats-to-date/m-p/556414#M74748</guid>
      <dc:creator>altijani</dc:creator>
      <dc:date>2019-05-06T13:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Format String with dashes and different formats to date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Format-String-with-dashes-and-different-formats-to-date/m-p/556420#M74749</link>
      <description>&lt;P&gt;Sure thing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
text_date="03/15/2015";output;
text_date="3/17/2016";output;
text_date="05/0/2015";output;
text_date="11/0/2016";output;
run;

data want;
   set have;
   text_date=tranwrd(text_date, '/0/', '/1/');
   Correct_date = input(text_date,mmddyy10.);
   format Correct_date mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 May 2019 14:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Format-String-with-dashes-and-different-formats-to-date/m-p/556420#M74749</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-06T14:00:38Z</dc:date>
    </item>
  </channel>
</rss>

