<?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: SAS limitation with IN operator in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SAS-limitation-with-IN-operator/m-p/97371#M27499</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Given OP query, Calendar_Month is a string. That's why the INPUT function is called. But the MONYY informat always returns the first of the month. Also, the documentation for the IN operator in SQL is clear: the parentheses must enclose a sequence of CONSTANTS or a query. Thus the condition can be simply written:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; WHERE INPUT(Calendar_Month, MONYY8.) IN ('01OCT2011'd, '01DEC2011'd); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Dec 2012 17:30:42 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2012-12-12T17:30:42Z</dc:date>
    <item>
      <title>SAS limitation with IN operator</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-limitation-with-IN-operator/m-p/97368#M27496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I need to get the below SAS SQL query working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Query: &lt;/P&gt;&lt;P&gt;=====&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;FROM STUDENT_FEE&lt;/P&gt;&lt;P&gt;WHERE INPUT(Calendar_Month, MONYY8.) IN (INPUT('Oct 2011', MONYY8.),INPUT('Dec 2011', MONYY8.));&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Issue:&amp;nbsp; Query execution itself fails.&lt;/P&gt;&lt;P&gt;===== &lt;/P&gt;&lt;P&gt;It seems in SAS, IN operator in the where clause doesn't accept any functions like INPUT, CAT etc. Again, this looks like a limitation in SAS. &lt;/P&gt;&lt;P&gt;Any other better way to rewrite the above query?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note:&lt;/P&gt;&lt;P&gt;====&lt;/P&gt;&lt;P&gt;Below query works fine. We can use SAS functions with any other operators like =, &amp;gt;, &amp;lt;, BETWEEN AND, etc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Query: &lt;/P&gt;&lt;P&gt;===========&lt;/P&gt;&lt;P&gt;SELECT *&lt;/P&gt;&lt;P&gt;FROM STUDENT_FEE&lt;/P&gt;&lt;P&gt;WHERE INPUT(Calendar_Month, MONYY8.) = INPUT('Dec 2011', MONYY8.);&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 08:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-limitation-with-IN-operator/m-p/97368#M27496</guid>
      <dc:creator>nitesh_k</dc:creator>
      <dc:date>2012-12-12T08:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAS limitation with IN operator</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-limitation-with-IN-operator/m-p/97369#M27497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would be tempted to use the INTNX function against Calendar_Month to return the first of the month, then you can just specify the exact dates in the IN clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHERE INTNX('MONTH',Calendar_Month,0) IN ('01Oct2011'd, '01Dec2011'd); &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 08:57:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-limitation-with-IN-operator/m-p/97369#M27497</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2012-12-12T08:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS limitation with IN operator</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-limitation-with-IN-operator/m-p/97370#M27498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you've tripped into one of the peculiarities of SQL. The contents of an IN condition can only be a query expression or a constant, whereas your syntax of the IN clause is a sql expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you just have the two conditions, the syntax that Keith gives you is perfect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have a lot of them, or if they change, put your numeric date values into a SAS dataset, and use this syntax:&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; INPUT(Calendar_Month, &lt;/SPAN&gt;&lt;SPAN style="color: #008080; font-size: 12pt; font-family: Courier New;"&gt;MONYY8.&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;IN&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; (&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; Condition_Month &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; Condition_Months);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 15:28:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-limitation-with-IN-operator/m-p/97370#M27498</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2012-12-12T15:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS limitation with IN operator</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-limitation-with-IN-operator/m-p/97371#M27499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Given OP query, Calendar_Month is a string. That's why the INPUT function is called. But the MONYY informat always returns the first of the month. Also, the documentation for the IN operator in SQL is clear: the parentheses must enclose a sequence of CONSTANTS or a query. Thus the condition can be simply written:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; WHERE INPUT(Calendar_Month, MONYY8.) IN ('01OCT2011'd, '01DEC2011'd); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Dec 2012 17:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-limitation-with-IN-operator/m-p/97371#M27499</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-12-12T17:30:42Z</dc:date>
    </item>
  </channel>
</rss>

