<?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: Convert Date strings to actual dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86299#M289124</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ANYDTDTE. informat almost does what you need but you need to tweak the data a bit (add a day), see example below:&lt;/P&gt;&lt;DIV style="font-family: Consolas; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;truncover&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dateString &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$32.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; @;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; mydate &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;anydtdte32.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; @;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; newDate = tranwrd( strip(dateString), &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;" "&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;" 1, "&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; newDate2 = input(newDate, &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;anydtdte32.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; mydate newDate2 &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;date9.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;January 2011&lt;BR /&gt;February 2011&lt;BR /&gt;March 2011&lt;BR /&gt;April 2011&lt;BR /&gt;May 2011&lt;BR /&gt;June 2011&lt;BR /&gt;July 2011&lt;BR /&gt;August 2011&lt;BR /&gt;September 2011&lt;BR /&gt;October 2011&lt;BR /&gt;November 2011&lt;BR /&gt;December 2011&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Jul 2013 08:00:35 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2013-07-24T08:00:35Z</dc:date>
    <item>
      <title>Convert Date strings to actual dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86294#M289119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I remember correctly there is a way inherently in sas to convert date strings (in word format) into actual number dates. Can anyone link the code that would accomplish this for the following date examples (none have days so I would like the day to default to 1).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;January 2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BECOMES&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1-1-2011&lt;/P&gt;&lt;P&gt;March 2009&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BECOMES&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3-1-2009.&lt;/P&gt;&lt;P&gt;ETC...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This also needs to happen inside of a proc sql step, so the code has to work in a proc sql step (which shouldn't eliminate anything, just wanted to bring it up just in-case). If there is not a specific informat for this, please let me know! (although I could swear I did something like this years ago with an informat).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table answer as&lt;/P&gt;&lt;P&gt;select input(date,DATEFORMATX.) as Dateanswer&lt;/P&gt;&lt;P&gt;from mytable;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All of the months values are fully spelled out with the 4 digit year attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Brandon&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2013 21:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86294#M289119</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-07-22T21:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date strings to actual dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86295#M289120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know of any that work.&amp;nbsp; You can use functions to pull it apart and put it back together in a format that does exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;date = input(cats(substr(char,1,3),scan(char,2)),monyy7.);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2013 22:00:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86295#M289120</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-07-22T22:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date strings to actual dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86296#M289121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Tom, yeah this is actually what I did in my current implimentation of the process, I was just curious because I could have sworn I'd seen one before.&lt;/P&gt;&lt;P&gt;Oh well, I can't seem to find it online, and if you also don't think one exists I probably just dreamt of it!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I gotta stop dreaming of SAS, there's probably a pill I can take for that......&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2013 22:08:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86296#M289121</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-07-22T22:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date strings to actual dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86297#M289122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You were probably thinking of the WORDDATE display format. Unfortunately there isn't a corresponding INFORMAT. There is MMMYY that reads things like JUN2013 without spaces and only the 3 letter abbreviation though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jul 2013 22:44:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86297#M289122</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-07-22T22:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date strings to actual dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86298#M289123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Another,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used the following method to deal with 'odd' dates in the past and it might be useful to you.&amp;nbsp; You will need to play around with to DO LOOP to capture the date range you are after, but the rest should remain unchanged.&amp;nbsp; If you are handling this type of date infrequently then it may not be worth your time.&amp;nbsp; We had a few systems where the format was the same and was causing us problems so this solution worked well for us.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA HAVE;&lt;/P&gt;&lt;P&gt;LENGTH DATES1 $14;&lt;/P&gt;&lt;P&gt;INPUT DATES1 $;&lt;/P&gt;&lt;P&gt;INFILE DATALINES DLM="," MISSOVER;&lt;/P&gt;&lt;P&gt;DATALINES;&lt;/P&gt;&lt;P&gt;January 2011&lt;/P&gt;&lt;P&gt;February 2011&lt;/P&gt;&lt;P&gt;March 2011&lt;/P&gt;&lt;P&gt;April 2011&lt;/P&gt;&lt;P&gt;May 2011&lt;/P&gt;&lt;P&gt;June 2011&lt;/P&gt;&lt;P&gt;July 2011&lt;/P&gt;&lt;P&gt;August 2011&lt;/P&gt;&lt;P&gt;September 2011&lt;/P&gt;&lt;P&gt;October 2011&lt;/P&gt;&lt;P&gt;November 2011&lt;/P&gt;&lt;P&gt;December 2011&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC FORMAT ;&lt;/P&gt;&lt;P&gt;PICTURE MONTHSYYYY LOW-HIGH = '%B %Y'&lt;/P&gt;&lt;P&gt;(DATATYPE = DATE) ;&lt;/P&gt;&lt;P&gt;RUN ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA INFMT ;&lt;/P&gt;&lt;P&gt;RETAIN FMTNAME "MONTHSYYYY" TYPE "I" ;&lt;/P&gt;&lt;P&gt;DO I = 1 TO 200;&lt;/P&gt;&lt;P&gt;LABEL = INTNX("MONTH",TODAY(),-I,"BEGINNING");&lt;/P&gt;&lt;P&gt;START = TRIM(LEFT(PUT(LABEL,MONTHSYYYY14.))) ;&lt;/P&gt;&lt;P&gt;OUTPUT ;&lt;/P&gt;&lt;P&gt;END ;&lt;/P&gt;&lt;P&gt;RUN ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC FORMAT CNTLIN = INFMT ;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;CREATE TABLE WANT AS&lt;/P&gt;&lt;P&gt;SELECT INPUT(DATES1,MONTHSYYYY14.) AS DATEANSWER FORMAT = MMDDYYD10.&lt;/P&gt;&lt;P&gt;FROM HAVE;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jul 2013 02:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86298#M289123</guid>
      <dc:creator>Scott_Mitchell</dc:creator>
      <dc:date>2013-07-23T02:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date strings to actual dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86299#M289124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ANYDTDTE. informat almost does what you need but you need to tweak the data a bit (add a day), see example below:&lt;/P&gt;&lt;DIV style="font-family: Consolas; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;truncover&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dateString &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$32.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; @;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; @&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; mydate &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;anydtdte32.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; @;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; newDate = tranwrd( strip(dateString), &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;" "&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;" 1, "&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; newDate2 = input(newDate, &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;anydtdte32.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; mydate newDate2 &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;date9.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;January 2011&lt;BR /&gt;February 2011&lt;BR /&gt;March 2011&lt;BR /&gt;April 2011&lt;BR /&gt;May 2011&lt;BR /&gt;June 2011&lt;BR /&gt;July 2011&lt;BR /&gt;August 2011&lt;BR /&gt;September 2011&lt;BR /&gt;October 2011&lt;BR /&gt;November 2011&lt;BR /&gt;December 2011&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jul 2013 08:00:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86299#M289124</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2013-07-24T08:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Date strings to actual dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86300#M289125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The anydtdte function (not anydate) function was the one I was looking for, thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 20:43:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-Date-strings-to-actual-dates/m-p/86300#M289125</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2013-08-08T20:43:05Z</dc:date>
    </item>
  </channel>
</rss>

