<?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 Character variable / string YYYYMM into a date in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Character-variable-string-YYYYMM-into-a-date/m-p/483135#M31320</link>
    <description>&lt;P&gt;Either your variable is defined as longer than 6 characters, or it does not have full 6 digits.&amp;nbsp; Or perhaps it is a number instead of a string? In which case it will get converted using the BEST12 format and so have 6 leading spaces before the 6 digit number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the CATS() function to insure the trailing and/or leading spaces are removed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(cats(t1.yr_mnth,"01"),yymmdd8.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 01 Aug 2018 17:47:32 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-08-01T17:47:32Z</dc:date>
    <item>
      <title>Convert Character variable / string YYYYMM into a date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Character-variable-string-YYYYMM-into-a-date/m-p/483131#M31318</link>
      <description>&lt;P&gt;I followed "Convert Character variable / string YYYYMM in date" solved discussion and entered the following code:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; WORK.QUERY_FOR_COMBINED_PANDG_MONTHLY &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;SELECT&lt;/FONT&gt; &lt;FONT color="#008000" face="Courier New" size="3"&gt;/* interval */&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;(input(t1.yr_mnth !! &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"01"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;yymmdd8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)) FORMAT=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;YYMMDD8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; LABEL=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"interval"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;AS&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; interval&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; PLCP.COMBINED_PANDG_MONTHLY_VOLUMES t1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;However, the results came back as dot (.).&amp;nbsp; Not sure what I did wrong.&amp;nbsp; Any help will be greatly appreciated.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Greg&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2018 17:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Character-variable-string-YYYYMM-into-a-date/m-p/483131#M31318</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2018-08-01T17:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character variable / string YYYYMM into a date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Character-variable-string-YYYYMM-into-a-date/m-p/483135#M31320</link>
      <description>&lt;P&gt;Either your variable is defined as longer than 6 characters, or it does not have full 6 digits.&amp;nbsp; Or perhaps it is a number instead of a string? In which case it will get converted using the BEST12 format and so have 6 leading spaces before the 6 digit number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could use the CATS() function to insure the trailing and/or leading spaces are removed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(cats(t1.yr_mnth,"01"),yymmdd8.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Aug 2018 17:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Character-variable-string-YYYYMM-into-a-date/m-p/483135#M31320</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-01T17:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character variable / string YYYYMM into a date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Character-variable-string-YYYYMM-into-a-date/m-p/483184#M31331</link>
      <description>&lt;P&gt;Thanks Tom, I just tried your code and it worked perfectly.&amp;nbsp; I appreciate your help and continue to learn.&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;</description>
      <pubDate>Wed, 01 Aug 2018 19:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Character-variable-string-YYYYMM-into-a-date/m-p/483184#M31331</guid>
      <dc:creator>gregor1</dc:creator>
      <dc:date>2018-08-01T19:53:27Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Character variable / string YYYYMM into a date</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Character-variable-string-YYYYMM-into-a-date/m-p/591860#M34758</link>
      <description>This is very helpful. Thanks.</description>
      <pubDate>Thu, 26 Sep 2019 13:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Convert-Character-variable-string-YYYYMM-into-a-date/m-p/591860#M34758</guid>
      <dc:creator>ho0421</dc:creator>
      <dc:date>2019-09-26T13:35:37Z</dc:date>
    </item>
  </channel>
</rss>

