<?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 How can I convert char to date in proc sql? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-char-to-date-in-proc-sql/m-p/782394#M249403</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set that has a column named MLYYM.&lt;/P&gt;&lt;P&gt;MLYYM has characters like 201801 (length 6).&lt;/P&gt;&lt;P&gt;I want to convert this column to date with format yyyymm.&lt;/P&gt;&lt;P&gt;I have to make where condition to compare this column value with macro variables(start date and end date)&lt;/P&gt;&lt;P&gt;ex. I have to subtract the data that MLYYM is between the start date(201601) and the end date(202112: this year's end month)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code below is what I tried. Could you help this out?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; CREATE TABLE TEST as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; SELECT&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; compress(MLYYM,'') as date1&amp;nbsp; &amp;nbsp; /* return length 6 character*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,input(compress(MLYYN, ''), yymmn6.) as date2. /*return length 8 numeric*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; FROM actr01;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Nov 2021 06:48:17 GMT</pubDate>
    <dc:creator>seohyeonjeong</dc:creator>
    <dc:date>2021-11-25T06:48:17Z</dc:date>
    <item>
      <title>How can I convert char to date in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-char-to-date-in-proc-sql/m-p/782394#M249403</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set that has a column named MLYYM.&lt;/P&gt;&lt;P&gt;MLYYM has characters like 201801 (length 6).&lt;/P&gt;&lt;P&gt;I want to convert this column to date with format yyyymm.&lt;/P&gt;&lt;P&gt;I have to make where condition to compare this column value with macro variables(start date and end date)&lt;/P&gt;&lt;P&gt;ex. I have to subtract the data that MLYYM is between the start date(201601) and the end date(202112: this year's end month)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code below is what I tried. Could you help this out?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; CREATE TABLE TEST as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; SELECT&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; compress(MLYYM,'') as date1&amp;nbsp; &amp;nbsp; /* return length 6 character*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ,input(compress(MLYYN, ''), yymmn6.) as date2. /*return length 8 numeric*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; FROM actr01;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 06:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-char-to-date-in-proc-sql/m-p/782394#M249403</guid>
      <dc:creator>seohyeonjeong</dc:creator>
      <dc:date>2021-11-25T06:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: How can I convert char to date in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-char-to-date-in-proc-sql/m-p/782399#M249408</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select
  *
from ACTR01
  where  input("&amp;amp;startdate", yymmn6.)  &amp;lt;= input(MLYYN, yymmn6.) &amp;lt;=  input("&amp;amp;enddate", yymmn6.) ;

   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 07:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-convert-char-to-date-in-proc-sql/m-p/782399#M249408</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-25T07:11:48Z</dc:date>
    </item>
  </channel>
</rss>

