<?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: IN operator is not supporting variable name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-is-not-supporting-variable-name/m-p/978889#M378692</link>
    <description>&lt;P&gt;As Freelancer showed you ,you should use array operator:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data demo;
    x=1;
run;

data demo3;
    set demo;
	array _x y z ;
    y=1;z=2;
    if x in _x then flag=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;P.S. variable z and _x must be not exist in dataset demo.&lt;/P&gt;</description>
    <pubDate>Sat, 15 Nov 2025 03:12:31 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-11-15T03:12:31Z</dc:date>
    <item>
      <title>IN operator is not supporting variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-is-not-supporting-variable-name/m-p/978865#M378690</link>
      <description>&lt;P&gt;I was surprised to find out that the IN operator is not supported variable names.&lt;/P&gt;
&lt;P&gt;If things change, just let me know&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p1n8bsqqd03xppn17pgvjpjlbhhs.htm#n0bcs3v4p8klexn1p2uvo1z9pg4s" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lepg/p1n8bsqqd03xppn17pgvjpjlbhhs.htm#n0bcs3v4p8klexn1p2uvo1z9pg4s&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data demo;
    x=1;
run;

data demo1;
    set demo;
    if x in (1,2) then flag=1;
run;

data demo2;
    set demo;
    y=1;
    if x = y or x =2 then flag=1;
run;

data demo3;
    set demo;
    y=1;
    if x in (y,2) then flag=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant, 
               a missing value, iterator, (.  
 
 ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Nov 2025 12:11:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-is-not-supporting-variable-name/m-p/978865#M378690</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2025-11-14T12:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: IN operator is not supporting variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-is-not-supporting-variable-name/m-p/978867#M378691</link>
      <description>&lt;P&gt;The &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0zs0pv38mel2jn1in4lte2akx4d.htm" target="_blank" rel="noopener"&gt;WHICHN&lt;/A&gt;/&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0jfvenvsqk24vn1q2ypospoq9ij.htm" target="_blank" rel="noopener"&gt;WHICHC&lt;/A&gt; functions provide a workaround in this situation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if whichn(x,y,2) then flag=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IN operator can also be applied to an array&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x in a then flag=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which, of course, must be defined earlier in the DATA step, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array a[*] y z (1 2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Nov 2025 13:12:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-is-not-supporting-variable-name/m-p/978867#M378691</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-11-14T13:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: IN operator is not supporting variable name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IN-operator-is-not-supporting-variable-name/m-p/978889#M378692</link>
      <description>&lt;P&gt;As Freelancer showed you ,you should use array operator:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data demo;
    x=1;
run;

data demo3;
    set demo;
	array _x y z ;
    y=1;z=2;
    if x in _x then flag=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;P.S. variable z and _x must be not exist in dataset demo.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Nov 2025 03:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IN-operator-is-not-supporting-variable-name/m-p/978889#M378692</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-11-15T03:12:31Z</dc:date>
    </item>
  </channel>
</rss>

