<?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 Where to convert variable when want to filter dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Where-to-convert-variable-when-want-to-filter-dates/m-p/592970#M170098</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to convert a character variable (YEAR_MONTH) to a numeric variable, which has been written in the code below. Please can someone change the line of code so that the dataset converts the variable and filter my dataset so that only observations are kept when the newly converted YEAR_MONTH numeric variable is less than or equal to 30 June 2018? Would it be possible to do this in one DATA step, or does it have to be done in two datasets (convert variable in first DATA step and then subset dataset in second DATA step)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;Where to include?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;YEAR_MONTH = input(YEAR_MONTH,6.);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set test2;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if YEAR_MONTH le '30Jun2018'd;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Oct 2019 10:13:09 GMT</pubDate>
    <dc:creator>jeremy4</dc:creator>
    <dc:date>2019-10-01T10:13:09Z</dc:date>
    <item>
      <title>Where to convert variable when want to filter dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-to-convert-variable-when-want-to-filter-dates/m-p/592970#M170098</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to convert a character variable (YEAR_MONTH) to a numeric variable, which has been written in the code below. Please can someone change the line of code so that the dataset converts the variable and filter my dataset so that only observations are kept when the newly converted YEAR_MONTH numeric variable is less than or equal to 30 June 2018? Would it be possible to do this in one DATA step, or does it have to be done in two datasets (convert variable in first DATA step and then subset dataset in second DATA step)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;Where to include?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;YEAR_MONTH = input(YEAR_MONTH,6.);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;set test2;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if YEAR_MONTH le '30Jun2018'd;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 10:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-to-convert-variable-when-want-to-filter-dates/m-p/592970#M170098</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-10-01T10:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: Where to convert variable when want to filter dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-to-convert-variable-when-want-to-filter-dates/m-p/592981#M170108</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266226"&gt;@jeremy4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am looking to convert a character variable (YEAR_MONTH) to a numeric variable,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is that 2018_06 (for example) or 201806?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the latter, then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   set test2;
   ym=input(year_month,yymmn6.);
   if ym le '30Jun2018'd;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 11:02:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-to-convert-variable-when-want-to-filter-dates/m-p/592981#M170108</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-10-01T11:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Where to convert variable when want to filter dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-to-convert-variable-when-want-to-filter-dates/m-p/592987#M170111</link>
      <description>&lt;P&gt;Why not to use WHERE clause?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   set test2;
   where input(year_month,yymmn6.) le '30Jun2018'd;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All the best&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 11:15:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-to-convert-variable-when-want-to-filter-dates/m-p/592987#M170111</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2019-10-01T11:15:54Z</dc:date>
    </item>
  </channel>
</rss>

