<?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 Convert Character YYYYMM date to datetime format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Convert-Character-YYYYMM-date-to-datetime-format/m-p/590151#M15001</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the below dataset.&lt;/P&gt;&lt;P&gt;I want another variable which has&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;format of &lt;STRONG&gt;datetime20&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;with last day of the respective month.(eg: for 201701 the date should be last date of the month --&lt;STRONG&gt;31JAN2017:00:00:00&lt;/STRONG&gt;)&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input character_date $6.;
datalines;
201701
201702
201703
201801
201802
201803
201901
201902
201903
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 19 Sep 2019 18:35:26 GMT</pubDate>
    <dc:creator>david27</dc:creator>
    <dc:date>2019-09-19T18:35:26Z</dc:date>
    <item>
      <title>Convert Character YYYYMM date to datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Character-YYYYMM-date-to-datetime-format/m-p/590151#M15001</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the below dataset.&lt;/P&gt;&lt;P&gt;I want another variable which has&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;format of &lt;STRONG&gt;datetime20&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;with last day of the respective month.(eg: for 201701 the date should be last date of the month --&lt;STRONG&gt;31JAN2017:00:00:00&lt;/STRONG&gt;)&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input character_date $6.;
datalines;
201701
201702
201703
201801
201802
201803
201901
201902
201903
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Sep 2019 18:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Character-YYYYMM-date-to-datetime-format/m-p/590151#M15001</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2019-09-19T18:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character YYYYMM date to datetime format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Convert-Character-YYYYMM-date-to-datetime-format/m-p/590161#M15002</link>
      <description>&lt;P&gt;Looks like this does what you request:&lt;/P&gt;
&lt;PRE&gt;data have;
input character_date $6.;
datetime = dhms(intnx('month',input(character_date,yymmn6.),0,'e'),0,0,0);

format datetime datetime18.;
datalines;
201701
201702
201703
201801
201802
201803
201901
201902
201903
;
run;&lt;/PRE&gt;
&lt;P&gt;Input with the correct informat will get you the first day of the month, the INTNX function with the 'e' alignment gets the last day of the month and the DHMS function turns a date and hour=0,minute=0 and second=0 into the desired datetime.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 19:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Convert-Character-YYYYMM-date-to-datetime-format/m-p/590161#M15002</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-19T19:20:00Z</dc:date>
    </item>
  </channel>
</rss>

