<?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 display datetime with missing day/month/second in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/display-datetime-with-missing-day-month-second/m-p/155594#M30441</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp; I am working on a program to display datetime variables with missing day/month/second information. The questions I have are&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;How to display a datetime as "01JAN2006/09:25". i.e replace the colon separating the date and time by slash and remove the second.&lt;/LI&gt;&lt;LI&gt;How to display a datetime as "JAN2006/Unknown" or "2006/Unknown" when day or month is missing?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jan 2014 15:09:12 GMT</pubDate>
    <dc:creator>Peter_Y</dc:creator>
    <dc:date>2014-01-29T15:09:12Z</dc:date>
    <item>
      <title>display datetime with missing day/month/second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/display-datetime-with-missing-day-month-second/m-p/155594#M30441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp; I am working on a program to display datetime variables with missing day/month/second information. The questions I have are&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;How to display a datetime as "01JAN2006/09:25". i.e replace the colon separating the date and time by slash and remove the second.&lt;/LI&gt;&lt;LI&gt;How to display a datetime as "JAN2006/Unknown" or "2006/Unknown" when day or month is missing?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jan 2014 15:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/display-datetime-with-missing-day-month-second/m-p/155594#M30441</guid>
      <dc:creator>Peter_Y</dc:creator>
      <dc:date>2014-01-29T15:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: display datetime with missing day/month/second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/display-datetime-with-missing-day-month-second/m-p/155595#M30442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First, to make use of SAS datetime values, a part of the datetime can't be 'missing'. The same should be valid from any reliable source system. If your datetime values have missing part, I assume they are in char format. This sounds like a candidate for char tweaking, not nay processing that includes SAS dateime function/formats.&lt;/P&gt;&lt;P&gt;What does your input look like?&lt;/P&gt;&lt;P&gt;1) In this case, convert to SAS datetime value by using a standard informat (depending on the format of your input data), Now, you can write your own picture format, which let's you do some formatting/logic, there are quite few directives that help you manipulate datetime values.&lt;/P&gt;&lt;P&gt;2) Can't se how this could work wit SAS date/datetime values, since they are numerical values that count days/seconds from 1Jan19060. So, here you probably need to do some character manipulating logic.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jan 2014 16:12:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/display-datetime-with-missing-day-month-second/m-p/155595#M30442</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-01-29T16:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: display datetime with missing day/month/second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/display-datetime-with-missing-day-month-second/m-p/155596#M30443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know if what you are trying to do is possible and still retaining the numeric aspect of date/time variables.&amp;nbsp; You would have to change them to character values and then do a "find and replace" (probably using the SUBSTR() function).&amp;nbsp; But this takes away all ability to use dates and time for their true nature.&amp;nbsp; You won't be able to properly sort or find differences between dates any more.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jan 2014 16:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/display-datetime-with-missing-day-month-second/m-p/155596#M30443</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2014-01-29T16:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: display datetime with missing day/month/second</title>
      <link>https://communities.sas.com/t5/SAS-Programming/display-datetime-with-missing-day-month-second/m-p/155597#M30444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi please see if this is what you want;program will also take care of consecutive missing months.&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;input date_have :datetime21.;&lt;/P&gt;&lt;P&gt;format date_have datetime21.;&lt;/P&gt;&lt;P&gt;diff=dif(datepart(date_have));&lt;/P&gt;&lt;P&gt;if dif(datepart(date_have))&amp;gt;1 then&lt;/P&gt;&lt;P&gt;do i=1 to diff-1;&lt;/P&gt;&lt;P&gt;date_have=date_have;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;date_have=date_have-24*60*60;&lt;/P&gt;&lt;P&gt;missing=1;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;01DEC2008:09:22:25&lt;/P&gt;&lt;P&gt;02DEC2008:10:23:45&lt;/P&gt;&lt;P&gt;04DEC2008:10:23:45&lt;/P&gt;&lt;P&gt;08DEC2008:10:23:45&lt;/P&gt;&lt;P&gt;10JAN2009:10:23:45&lt;/P&gt;&lt;P&gt;20FEB2009:10:23:45&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc sort data=test;&lt;/P&gt;&lt;P&gt;by date_have;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data test(keep=date_want);&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;date_have_char=put(date_have,datetime21.);&lt;/P&gt;&lt;P&gt;date_want=catx('/',scan(date_have_char,1,':'),catx(':',scan(date_have_char,2,':'),scan(date_have_char,3,':'))) ;&lt;/P&gt;&lt;P&gt;if missing=1 then date_want=catx('/',put(datepart(date_have),monyy7.),'UNKNOWN');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;OUTPUT:&lt;/P&gt;&lt;P&gt;--------------&lt;/P&gt;&lt;P&gt;date_want=01DEC2008/09:22&lt;/P&gt;&lt;P&gt;date_want=02DEC2008/10:23&lt;/P&gt;&lt;P&gt;date_want=DEC2008/UNKNOWN&lt;/P&gt;&lt;P&gt;date_want=04DEC2008/10:23&lt;/P&gt;&lt;P&gt;date_want=DEC2008/UNKNOWN&lt;/P&gt;&lt;P&gt;date_want=DEC2008/UNKNOWN&lt;/P&gt;&lt;P&gt;date_want=DEC2008/UNKNOWN&lt;/P&gt;&lt;P&gt;date_want=08DEC2008/10:23&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;date_want=JAN2009/UNKNOWN&lt;/P&gt;&lt;P&gt;date_want=10JAN2009/10:23&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;date_want=FEB2009/UNKNOWN&lt;/P&gt;&lt;P&gt;date_want=20FEB2009/10:23&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jan 2014 19:43:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/display-datetime-with-missing-day-month-second/m-p/155597#M30444</guid>
      <dc:creator>pradeepalankar</dc:creator>
      <dc:date>2014-01-29T19:43:43Z</dc:date>
    </item>
  </channel>
</rss>

