<?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: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665703#M199094</link>
    <description>&lt;P&gt;So you want to convert unusable garbage to even less usable garbage.&lt;/P&gt;
&lt;P&gt;There's no sense in that.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jun 2020 05:37:24 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-06-29T05:37:24Z</dc:date>
    <item>
      <title>Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665692#M199086</link>
      <description>&lt;P&gt;Hi I want to convert multiple variables in iso to DD-MMM-YYYY (18JUNE2018).&lt;/P&gt;&lt;P&gt;it also have partial dates for some date values&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there any method to do that?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 05:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665692#M199086</guid>
      <dc:creator>ambadi007</dc:creator>
      <dc:date>2020-06-29T05:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665694#M199087</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; I want to convert multiple variables in iso&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;There are several ISO variations. Show what you have.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;gt;it also have partial dates for some date values&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Even more reason to show your data&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 05:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665694#M199087</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-29T05:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665696#M199089</link>
      <description>&lt;P&gt;SAS has about 20 different ISO related informats and formats because there are that many "standards". You need to show us some actual examples of the values you have for best advice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And specifically show what the "partial dates" as well look like. As I understand ISO such a thing can't actually occur if the value is actually ISO.&lt;/P&gt;
&lt;P&gt;Copy the values from a TEXT document as and paste the results into a code box opened with the &amp;lt;/&amp;gt; icon on the forum. That will preserve formatting. Anything pasted into the main message windows will get reformatted, usually loosing white space characters and such which could invalidate any code suggestions for your actual data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 05:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665696#M199089</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-29T05:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665697#M199090</link>
      <description>the dates will be&lt;BR /&gt;2018-08-26&lt;BR /&gt;2018-07 (partial date day missing)- so this should be 2018-Jul&lt;BR /&gt;2019 (month and day missing) etc... this should be 2019&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Jun 2020 05:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665697#M199090</guid>
      <dc:creator>ambadi007</dc:creator>
      <dc:date>2020-06-29T05:17:45Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665699#M199091</link>
      <description>&lt;P&gt;What's the expected output? A SAS date? A string? What date do you want when the month or day are missing?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 05:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665699#M199091</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-29T05:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665701#M199092</link>
      <description>&lt;P&gt;The dates should be in text.&lt;/P&gt;&lt;P&gt;if the date are full the output date should be looks like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;29Jun2020&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if month missing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;29---2020&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if day missing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jun2020&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if day and month missing&amp;nbsp;&lt;/P&gt;&lt;P&gt;2020&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 05:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665701#M199092</guid>
      <dc:creator>ambadi007</dc:creator>
      <dc:date>2020-06-29T05:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665702#M199093</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76823"&gt;@ambadi007&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;the dates will be&lt;BR /&gt;2018-08-26&lt;BR /&gt;2018-07 (partial date day missing)- so this should be 2018-Jul&lt;BR /&gt;2019 (month and day missing) etc... this should be 2019&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since the value SAS will create is a complete date what day of the month should be imputed for the Year month? And what month and day should be imputed when only the year is present?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are very likely much better off creating a SAS date value instead of a character variable because 1) SAS dates sort properly, 2) you can change appearance with format changes without having to recreate a bunch of new variables and 3) the functions that SAS supplies to manipulate dates, or that use dates in time-series analyis, expect the numeric SAS valued date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Anydtdte. informat will assume that 4 digits delimited is a year and guesses that the second is the month when no day is provided. The resulting date uses the first of the month.&lt;/P&gt;
&lt;P&gt;Since there is no way for anyone to reliably know that a date of 4 digits is only a year you need to provide code to account for that case. The MDY (month day year) function creates a date value given the number of month, day and year. So I provide an example that will assume month and day are 1. If you want a different assumed day and and month&amp;nbsp; for only year values you can set it there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   input datetext :$10.;
   date=input(datetext,anydtdte.);
   /* the following assumes the month,first parameter is 1 and day is 1*/
   if length( datetext)=4 then date=mdy(1,1,input(datetext,f4.));
   format date date11.;
datalines;
2018-08-26
2018-07 
2019
;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 05:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665702#M199093</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-29T05:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665703#M199094</link>
      <description>&lt;P&gt;So you want to convert unusable garbage to even less usable garbage.&lt;/P&gt;
&lt;P&gt;There's no sense in that.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 05:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665703#M199094</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-29T05:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665704#M199095</link>
      <description>&lt;P&gt;As of now I dont want to impute anything for partial dates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;full date- 29Jun2020&lt;/P&gt;&lt;P&gt;if day missing it can be like --Jun2020&lt;/P&gt;&lt;P&gt;if month is missing 29---2020&lt;/P&gt;&lt;P&gt;if day and month is missing then only year 2020 needed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is the requirement needed&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 05:51:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665704#M199095</guid>
      <dc:creator>ambadi007</dc:creator>
      <dc:date>2020-06-29T05:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665707#M199097</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;29Jun2020&lt;/P&gt;
&lt;P&gt;29---2020&lt;/P&gt;
&lt;P&gt;Jun2020&lt;/P&gt;
&lt;P&gt;2020&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can you tell how are you going to use these values? I am curious now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more typical outcome, here is another method:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  A='2018-08-26'; output;
  A='2018-07   '; output;
  A='2019      '; output;
run;

proc format;
  invalue anydt (default=24)
    's/\A(\d{4}) *\Z/\1-01-01/  ' (regexpe)= [yymmdd10.] 
    's/(\A\d{4}-\d\d) *\Z/\1-01/' (regexpe)= [yymmdd10.] 
    'm/\A\d{4}-\d\d-\d\d *\Z/   ' (regexp) = [yymmdd10.] 
  other                                   =  .;
run;     

data WANT;
  set HAVE;
  B = input(A,anydt.); putlog B=;
  format B date9. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;B=26AUG2018&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;B=01JUL2018&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;B=01JAN2019&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 06:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665707#M199097</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-29T06:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665710#M199099</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76823"&gt;@ambadi007&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As of now I dont want to impute anything for partial dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;full date- 29Jun2020&lt;/P&gt;
&lt;P&gt;if day missing it can be like --Jun2020&lt;/P&gt;
&lt;P&gt;if month is missing 29---2020&lt;/P&gt;
&lt;P&gt;if day and month is missing then only year 2020 needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is the requirement needed&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then you don't have a date, but a hardly usable text-variable.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 06:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665710#M199099</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-06-29T06:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Converting iso format (character) dates in to DD-MMM-YYYY (character) format for multiple variab</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665796#M199124</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76823"&gt;@ambadi007&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As of now I dont want to impute anything for partial dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;full date- 29Jun2020&lt;/P&gt;
&lt;P&gt;if day missing it can be like --Jun2020&lt;/P&gt;
&lt;P&gt;if month is missing 29---2020&lt;/P&gt;
&lt;P&gt;if day and month is missing then only year 2020 needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is the requirement needed&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And you have now introduced yet another type of data error -the missing month with day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PLEASE explain how 29---2019 is more usable than 2019-&amp;nbsp; -29, or however that would have originated. At least the problematic value you have now will sort somewhat, your proposed result won't do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 14:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-iso-format-character-dates-in-to-DD-MMM-YYYY/m-p/665796#M199124</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-29T14:12:36Z</dc:date>
    </item>
  </channel>
</rss>

