<?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: Different date format to single format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Different-date-format-to-single-format/m-p/698100#M213464</link>
    <description>&lt;P&gt;EDIT: i removed my "solution" after reading the fully valid comment by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Nov 2020 08:32:54 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-11-11T08:32:54Z</dc:date>
    <item>
      <title>Different date format to single format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Different-date-format-to-single-format/m-p/698091#M213459</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I need to convert the texted date variable to a particular format.&lt;/P&gt;
&lt;P&gt;Eg:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input R_Date$20.;
cards;
31/01/2000
15/3/2015
30-5-2010
30-12-2018
31/7/20
15/2/12
18/05/15
11-08-08
2000
1998
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Expected result&lt;/P&gt;
&lt;TABLE width="75"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="75"&gt;01/31/2000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;03/15/2015&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;05/30/2010&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;12/30/2018&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;07/31/2020&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;02/15/2012&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;05/18/2015&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;08/11/2008&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;01/01/2000&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;01/01/1998&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kindly suggest a code to get MM/DD/YYYY format.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 07:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Different-date-format-to-single-format/m-p/698091#M213459</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2020-11-11T07:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Different date format to single format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Different-date-format-to-single-format/m-p/698099#M213463</link>
      <description>&lt;P&gt;This is not data, this is unusable crap.&lt;/P&gt;
&lt;PRE&gt;11-08-08&lt;/PRE&gt;
&lt;P&gt;could be&lt;/P&gt;
&lt;P&gt;2011-08-08&lt;/P&gt;
&lt;P&gt;2008-08-11&lt;/P&gt;
&lt;P&gt;2008-11-08&lt;/P&gt;
&lt;P&gt;not even the year can be determined with any confidence. So there simply is no way to &lt;U&gt;reliably&lt;/U&gt; make dates out of this. And reliable processes are what we need and strive for. To roll dice, I don't need a data warehouse.&lt;/P&gt;
&lt;P&gt;Anybody who still uses 2-digit years after Y2K is * ***** ***** in my eyes, and needs to be cared for in a proper institution for the mentally challenged.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Print that "data" on a sheet, wrap it around a baseball bat, and go to the person that sent you this. Apply the baseball bat liberally. Maybe some neurons get into contact and start to fire.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for my rant, but things like this severely damage my belief in a long-term future for the human species.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS anybody who finds exaggeration or irony can keep it and use it freely.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 08:29:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Different-date-format-to-single-format/m-p/698099#M213463</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-11T08:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: Different date format to single format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Different-date-format-to-single-format/m-p/698100#M213464</link>
      <description>&lt;P&gt;EDIT: i removed my "solution" after reading the fully valid comment by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 08:32:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Different-date-format-to-single-format/m-p/698100#M213464</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-11-11T08:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Different date format to single format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Different-date-format-to-single-format/m-p/698179#M213496</link>
      <description>&lt;P&gt;So are you assuming the values should be in DMY order?&amp;nbsp; If so use the DDMMYY informat.&amp;nbsp; If you want to get the year only values you will need to add more logic to handle those cases.&lt;/P&gt;
&lt;P&gt;I wouldn't compound the confusing by using either DMY or MDY order for displaying the derived dates. Use an unambiguous format like YYMMDD10. or DATE9. .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  date=coalesce(input(r_date,??ddmmyy10.),input(r_date,??anydtdte20.));
  if missing(date) and length(r_date)=4 and not missing(input(r_date,??4.))
    then date=mdy(1,1,input(r_date,4.))
  ;
  format date yymmdd10.;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    R_Date              date

  1    31/01/2000    2000-01-31
  2    15/3/2015     2015-03-15
  3    30-5-2010     2010-05-30
  4    30-12-2018    2018-12-30
  5    31/7/20       2020-07-31
  6    15/2/12       2012-02-15
  7    18/05/15      2015-05-18
  8    11-08-08      2008-08-11
  9    2000          2000-01-01
 10    1998          1998-01-01&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 16:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Different-date-format-to-single-format/m-p/698179#M213496</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-11T16:14:31Z</dc:date>
    </item>
  </channel>
</rss>

