<?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: how to re-format dates in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91507#M645</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;Your code treats 112012 as 11/2012, it should be 01/01/2012. there is a link in this post &lt;A _jive_internal="true" href="https://communities.sas.com/message/109024#109024"&gt;https://communities.sas.com/message/109024#109024&lt;/A&gt;&lt;/P&gt;&lt;P&gt;, it maybe helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks - Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 21 Apr 2012 13:16:12 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2012-04-21T13:16:12Z</dc:date>
    <item>
      <title>how to re-format dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91505#M643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In a dataset when there are a mixture of date formats as the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;event&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; holidays&lt;/P&gt;&lt;P&gt;New Year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/01/2012&lt;/P&gt;&lt;P&gt;New Year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01012012&lt;/P&gt;&lt;P&gt;New Year&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 112012&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;note the last one has all the zeros missing.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;what are the methods to re-format all the dates in the column, holidays, to have a format of mm/dd/yyyy?&amp;nbsp; thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Apr 2012 22:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91505#M643</guid>
      <dc:creator>Cyndia</dc:creator>
      <dc:date>2012-04-20T22:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to re-format dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91506#M644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;Below code doesn't provide a valid solution. Please refer to Linlin's post as per why.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on your posted data the variable 'holidays' must be a character variable containing strings which stand for a date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you want to do is convert such strings into a numeric value which stands for a SAS date and then apply a SAS date format on this numeric variable so that when printing this numeric value it shows up as a date string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use a SAS INFORMAT to read a string and convert it to a numeric value (=a SAS date informat). Use a SAS FORMAT to convert a numeric value to a string (eg. a SAS date to a date string).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; infile datalines truncover dsd;&lt;BR /&gt;&amp;nbsp; input event:$20. Char_Holidays :$10.;&lt;BR /&gt;&amp;nbsp; format Holidays mmddyy10.;&lt;BR /&gt;&amp;nbsp; datalines;&lt;BR /&gt;New Year,01/01/2012&lt;BR /&gt;New Year,01012012&lt;BR /&gt;New Year,112012&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; format Holidays mmddyy10.;&lt;BR /&gt;&amp;nbsp; Holidays=input(Char_holidays,mmddyy10.);&lt;BR /&gt;&amp;nbsp; Standardized_Char_Holidays=put(input(Char_holidays,mmddyy10.),mmddyy10.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=want;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;N.B: A SAS date value are the number of days since 1/1/1960.&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; date='01jan1960'd;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do while(date&amp;lt;='01jan2010'd);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; put date= @20 date= date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date=intnx('year10',date,1,'s');&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Apr 2012 02:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91506#M644</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-04-21T02:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: how to re-format dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91507#M645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;Your code treats 112012 as 11/2012, it should be 01/01/2012. there is a link in this post &lt;A _jive_internal="true" href="https://communities.sas.com/message/109024#109024"&gt;https://communities.sas.com/message/109024#109024&lt;/A&gt;&lt;/P&gt;&lt;P&gt;, it maybe helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks - Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Apr 2012 13:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91507#M645</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-04-21T13:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to re-format dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91508#M646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How about ANYDTDTE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines truncover dsd;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input event:$20. Char_Holidays :ANYDTDTE.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format Char_Holidays mmddyy10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;New Year,01/01/2012&lt;/P&gt;&lt;P&gt;New Year,01012012&lt;/P&gt;&lt;P&gt;New Year,112012&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Apr 2012 16:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91508#M646</guid>
      <dc:creator>shivas</dc:creator>
      <dc:date>2012-04-21T16:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to re-format dates</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91509#M647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Linlin you're of course right and I missed this one. Actually without knowing more about the possible datestrings to deal with I can't think of a one-fits-all solution.&lt;/P&gt;&lt;P&gt;Eg. 1122012&amp;nbsp; That could be 01Dec2012 or 11Feb2012.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@shivas:&lt;/P&gt;&lt;P&gt;Using ANYDTDTE. doesn't solve this issue. But when using ANYDTDTE. you best use also "option datestyle=..." or you might get unexpected results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Apr 2012 00:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/how-to-re-format-dates/m-p/91509#M647</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-04-22T00:49:48Z</dc:date>
    </item>
  </channel>
</rss>

