<?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: Data Step subsetting throwing errors in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777265#M247245</link>
    <description>Line generated by the macro variable "TODAY".</description>
    <pubDate>Fri, 29 Oct 2021 12:41:08 GMT</pubDate>
    <dc:creator>inquistive</dc:creator>
    <dc:date>2021-10-29T12:41:08Z</dc:date>
    <item>
      <title>Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777261#M247243</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;I am stuck on a very simple code. Quick help is appreciated. I have code like this:&lt;/P&gt;&lt;P&gt;Data farmer;&lt;/P&gt;&lt;P&gt;set agriculture;&lt;/P&gt;&lt;P&gt;if land_ownership = 'YES' and &amp;amp;today. between&amp;nbsp; ownership_start_date and ownership_end_date; &lt;FONT size="2"&gt;(Please note '&amp;amp;today.' is predefined and global macro available in library)&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;This throws following errors: 388-185: Expecting an arithmetic error.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200-322:&amp;nbsp; the symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 76-322: Syntax error, statement will be ignored.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 12:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777261#M247243</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2021-10-29T12:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777263#M247244</link>
      <description>&lt;P&gt;When there are errors in the log, please show us (and in the future every time this happens please show us) the entire LOG for this entire section of code, all of it, every single line of the log for this section of code. Please do not show us the errors disconnected from the code. Please format the log properly by copying the log as text and pasting it into the window that appears here at the SAS Communities when you click on the &amp;lt;/&amp;gt; icon.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;We also need to see the actual value of macro variable &amp;amp;today&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 12:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777263#M247244</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-29T12:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777265#M247245</link>
      <description>Line generated by the macro variable "TODAY".</description>
      <pubDate>Fri, 29 Oct 2021 12:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777265#M247245</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2021-10-29T12:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777267#M247246</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83652"&gt;@inquistive&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Line generated by the macro variable "TODAY".&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't understand. And this is not the log that I requested.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 12:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777267#M247246</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-29T12:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777270#M247248</link>
      <description>Thank you for your support. However, I can't show the log here(I said 'code look LIKE this'). I am just seeking advice on what has gone wrong in the syntax that SAS is objecting to.</description>
      <pubDate>Fri, 29 Oct 2021 12:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777270#M247248</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2021-10-29T12:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777272#M247249</link>
      <description>&lt;P&gt;It's really hard to say anything if you can't show us the log, and I assume you can't show us the data either. We can guess, but often the guess is way off.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 13:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777272#M247249</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-29T13:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777278#M247251</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83652"&gt;@inquistive&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the DATA step, the &lt;A href="https://documentation.sas.com/doc/en/lrcon/9.4/p0eaz2e63dlj17n1i5z17z3h84vp.htm#p0pv1ejkggqngzn19zfivd5pbari" target="_blank" rel="noopener"&gt;BETWEEN-AND operator&lt;/A&gt; is valid only in WHERE conditions. So, either use a WHERE statement instead of an IF statement (if this is possible in your real code) or use the "&amp;lt;=" operator (or its mnemonic LE).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if land_ownership = 'YES' and ownership_start_date &amp;lt;= &amp;amp;today. &amp;lt;= ownership_end_date;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are likely more issues in your code because neither the error "&lt;SPAN&gt;200-322" nor the note "Line generated by&amp;nbsp;..." should occur if macro variable TODAY contained a valid SAS date value such as &lt;FONT face="courier new,courier"&gt;'29OCT2021'd&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;22582&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 13:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777278#M247251</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-10-29T13:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777280#M247252</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm assuming you can't show the real code / log because it has confidential information of some sort.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In such a case, the best thing to do is create a non-confidential test case&amp;nbsp; which reproduces the problem (using a small data step with data from the CARDS statement or whatever fake data).&amp;nbsp; Then you can post that the real code and log from the test case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my experience, about 50% of the time when you try to make a small test case to replicate the problem in preparation for posting a question, it in fact does NOT replicate the problem (surprisingly).&amp;nbsp; And then you realize the problem is not where you thought it was, and you end up solving the problem yourself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And in the 50% of the cases where you can't solve it yourself, by posting actual sample code and log that shows the error, you double your chances of getting a quick solution from the community.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 13:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777280#M247252</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-10-29T13:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777286#M247255</link>
      <description>Thank you! @FreelanceReinhard.You saved my day!!</description>
      <pubDate>Fri, 29 Oct 2021 13:51:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777286#M247255</guid>
      <dc:creator>inquistive</dc:creator>
      <dc:date>2021-10-29T13:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777323#M247273</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83652"&gt;@inquistive&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you! @FreelanceReinhard.You saved my day!!&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Be aware that if you have missing values for a variable they are always less than any actual value.&lt;/P&gt;
&lt;P&gt;So use of&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;if land_ownership = 'YES' and ownership_start_date &amp;lt;= &amp;amp;today. &amp;lt;= ownership_end_date;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;would return records where Ownership_start_date is missing. From context you might not think that important but I find stupid things involving dates all the time. Like dates of birth after the date of a medical service, end dates occurring before start dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also if the Ownership_end_date is missing it will not return an observation. Since end dates may be missing depending on context of your data until the actual end occurs this is something to consider.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 15:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777323#M247273</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-29T15:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Data Step subsetting throwing errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777356#M247294</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Be aware that if you have missing values for a variable they are always less than any actual value.&lt;/P&gt;
&lt;P&gt;So use of&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;if land_ownership = 'YES' and ownership_start_date &amp;lt;= &amp;amp;today. &amp;lt;= ownership_end_date;&lt;/LI-CODE&gt;
&lt;P&gt;would return records where Ownership_start_date is missing. From context you might not think that important but I find stupid things involving dates all the time. Like dates of birth after the date of a medical service, end dates occurring before start dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also if the Ownership_end_date is missing it will not return an observation. Since end dates may be missing depending on context of your data until the actual end occurs this is something to consider.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sometimes I do stuff like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if land_ownership = 'YES' and .Z &amp;lt; ownership_start_date &amp;lt;= &amp;amp;today. &amp;lt;= ownership_end_date;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to make explicit that all the values need to be non-missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.lexjansen.com/nesug/nesug12/cc/cc31.pdf" target="_blank"&gt;Or, since&lt;/A&gt; I'm a fan of assertions to validate expectations, I add an assertion that will throw an error if ownership_start_date or ownership_end_date are missing (or in wrong order):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%assert(land_ownership IN ("YES" "NO"))
%assert(.Z &amp;lt; ownership_start_date &amp;lt;= ownership_end_date )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With %assert defined like:&amp;nbsp; &lt;A href="https://www.lexjansen.com/nesug/nesug12/cc/cc31.pdf" target="_blank"&gt;https://www.lexjansen.com/nesug/nesug12/cc/cc31.pdf&lt;/A&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 16:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Step-subsetting-throwing-errors/m-p/777356#M247294</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-10-29T16:41:46Z</dc:date>
    </item>
  </channel>
</rss>

