<?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: Month-Year in if/where Statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834102#M329778</link>
    <description>I tried the code from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; and it worked. Thanks both!</description>
    <pubDate>Mon, 19 Sep 2022 13:52:04 GMT</pubDate>
    <dc:creator>Bright</dc:creator>
    <dc:date>2022-09-19T13:52:04Z</dc:date>
    <item>
      <title>Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834091#M329768</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a variable called&amp;nbsp;month_year in dataset DATA1 with format&amp;nbsp;MONYY7.&lt;/P&gt;
&lt;P&gt;I am trying to make a subset of this datset based on the variable&amp;nbsp;month_year. My code for getting the observations where&amp;nbsp;month_year&amp;nbsp; is not March 2015 looks like this:&lt;/P&gt;
&lt;PRE&gt;data DATA2 (where=(month_year ne 'MAR2015'd));
set  DATA1;
run;&lt;/PRE&gt;
&lt;P&gt;I am getting the error "ERROR: Invalid date/time/datetime constant 'MAR2015'd.&lt;BR /&gt;ERROR: Syntax error while parsing WHERE clause."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 13:36:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834091#M329768</guid>
      <dc:creator>Bright</dc:creator>
      <dc:date>2022-09-19T13:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834092#M329769</link>
      <description>&lt;P&gt;&amp;nbsp;What is your desired result? To get all obs where the date is in March 2015?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 13:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834092#M329769</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-19T13:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834093#M329770</link>
      <description>The desired output is to get all observations where the date is not March 2015.</description>
      <pubDate>Mon, 19 Sep 2022 13:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834093#M329770</guid>
      <dc:creator>Bright</dc:creator>
      <dc:date>2022-09-19T13:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834094#M329771</link>
      <description>&lt;P&gt;Date values in SAS are integers. So March2015 is not a date in itself.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this is what you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DATA2;
   set DATA1;
   where month_year &amp;gt; '31MAR2015'd or month_year &amp;lt; '01MAR2015'd;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Sep 2022 13:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834094#M329771</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-19T13:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834095#M329772</link>
      <description>Thanks, but I only have month and year (i.e., MAR2015). I do not have the day (i.e., 31MAR2015).</description>
      <pubDate>Mon, 19 Sep 2022 13:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834095#M329772</guid>
      <dc:creator>Bright</dc:creator>
      <dc:date>2022-09-19T13:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834096#M329773</link>
      <description>&lt;P&gt;Adding to the correct comments from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;, the only correct format to enter SAS day values is either the number of days since January 1, 1960 (which most people probably don't know), or as a data literal, which must be in this exact format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'19MAR2015'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;except that you can use lower case or mixed case letters, and (if you want, but really you shouldn't do this) you can use 2 digit years in some cases. So following this rule, your original code of 'MAR2015'd does not fit this format and so can't be used.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 13:39:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834096#M329773</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-19T13:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834097#M329774</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/307632"&gt;@Bright&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks, but I only have month and year (i.e., MAR2015). I do not have the day (i.e., 31MAR2015).&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please provide more information. Is this variable character or numeric, according to PROC CONTENTS? Show us a typical value.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 13:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834097#M329774</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-19T13:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834098#M329775</link>
      <description>month_year in dataset DATA1 has format MONYY7.&lt;BR /&gt;For example MAR2015.</description>
      <pubDate>Mon, 19 Sep 2022 13:43:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834098#M329775</guid>
      <dc:creator>Bright</dc:creator>
      <dc:date>2022-09-19T13:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834100#M329776</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/307632"&gt;@Bright&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;month_year in dataset DATA1 has format MONYY7.&lt;BR /&gt;For example MAR2015.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So, because the format is MONYY7., it must be numeric. Obviously, you did not try the code from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;which looks correct to me. Please try it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: SAS dates always contain month and day and year, even if it is displayed differently.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 13:45:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834100#M329776</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-19T13:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834102#M329778</link>
      <description>I tried the code from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; and it worked. Thanks both!</description>
      <pubDate>Mon, 19 Sep 2022 13:52:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834102#M329778</guid>
      <dc:creator>Bright</dc:creator>
      <dc:date>2022-09-19T13:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Month-Year in if/where Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834124#M329787</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Adding to the correct comments from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;&amp;nbsp;, the only correct format to enter SAS day values is either the number of days since January 1, 1960 (which most people probably don't know), or as a data literal, which must be in this exact format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;'19MAR2015'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;except that you can use lower case or mixed case letters, and (if you want, but really you shouldn't do this) you can use 2 digit years in some cases. So following this rule, your original code of 'MAR2015'd does not fit this format and so can't be used.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The easier rule to remember is it needs to be something that the DATE &lt;STRONG&gt;informat&lt;/STRONG&gt; will understand.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'01-mar-2015'd
"1 mar 15"d
'1MAR2015'd
etc.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2022 16:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Month-Year-in-if-where-Statement/m-p/834124#M329787</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-19T16:11:33Z</dc:date>
    </item>
  </channel>
</rss>

