<?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: character to date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195425#M36778</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you give an example (or two) of what DATEINCHAR looks like and what you want DATE_SAS to look like?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 May 2015 17:21:40 GMT</pubDate>
    <dc:creator>djbateman</dc:creator>
    <dc:date>2015-05-28T17:21:40Z</dc:date>
    <item>
      <title>character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195424#M36777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My year field has been stored in character field of 25 length.&lt;/P&gt;&lt;P&gt;I want to convert this to date field with years.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried this code but the output is empty&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;date_sas=input(put(dateinchar, 4.), yymmdd8.);&lt;/P&gt;&lt;P&gt;format date_sas date 9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 16:58:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195424#M36777</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-05-28T16:58:44Z</dc:date>
    </item>
    <item>
      <title>Re: character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195425#M36778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you give an example (or two) of what DATEINCHAR looks like and what you want DATE_SAS to look like?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 17:21:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195425#M36778</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2015-05-28T17:21:40Z</dc:date>
    </item>
    <item>
      <title>Re: character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195426#M36779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dateinchar (this field is defined as character in the input file length - 25)&lt;/P&gt;&lt;P&gt;2004&lt;/P&gt;&lt;P&gt;2005&lt;/P&gt;&lt;P&gt;1999&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dateinsas ( I want this to be defined as date field, length could be 4 digits)&lt;/P&gt;&lt;P&gt;2004&lt;/P&gt;&lt;P&gt;2005&lt;/P&gt;&lt;P&gt;1999&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 17:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195426#M36779</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-05-28T17:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195427#M36780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does this help?&amp;nbsp; I converted the 4-digit character year into a 4-digit numeric year (DATEINNUM), but I also converted it into a SAS date (DATEINSAS) using the MDY() function where I assumed the month was January and the day was the 1st.&amp;nbsp; If you want a different month/day value, you can change those as you see fit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data dates;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length dateinchar $25;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input dateinchar $;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format dateinsas yymmdd8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dateinnum=input(dateinchar,4.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; dateinsas=mdy(1,1,input(dateinchar,4.));&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;2004&lt;/P&gt;&lt;P&gt;2005&lt;/P&gt;&lt;P&gt;1999&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 17:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195427#M36780</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2015-05-28T17:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195428#M36781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, It doesn't work. &lt;/P&gt;&lt;P&gt;For example when input&amp;nbsp; = 2007 , it gives 07-01-01 whereas I want output = 2007 (but the field being defined as a date field)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 17:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195428#M36781</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-05-28T17:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195429#M36782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will need to change the date format to what you want it to look like.&amp;nbsp; Instead of &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;YYMMDD8. try YEAR. in its place:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data dates;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; length dateinchar $25;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; input dateinchar $;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; format dateinsas year.;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; dateinnum=input(dateinchar,4.);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; dateinsas=mdy(1,1,&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;dateinnum&lt;/SPAN&gt;);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;2004&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;2005&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1999&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 17:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195429#M36782</guid>
      <dc:creator>djbateman</dc:creator>
      <dc:date>2015-05-28T17:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: character to date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195430#M36783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;this worked. We dont need to convert this to numeric. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;format dateinsas year.;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;dateinsas=mdy(1,1,&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;dateinchar&lt;/SPAN&gt;);&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thanks!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2015 17:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/character-to-date/m-p/195430#M36783</guid>
      <dc:creator>buckeyefisher</dc:creator>
      <dc:date>2015-05-28T17:57:55Z</dc:date>
    </item>
  </channel>
</rss>

