<?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: Looking for documentation on why IF IN over variable &amp;quot;array&amp;quot; works in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629360#M20738</link>
    <description>&lt;P&gt;The second usage of "in" indicates, that a function named "in" exists, returning the very same result as the in-operator.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Mar 2020 06:18:42 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-03-04T06:18:42Z</dc:date>
    <item>
      <title>Looking for documentation on why IF IN over variable "array" works</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629280#M20729</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I've stumbled upon some IF IN () syntax that works, but I cannot find any documentation as to why or how it works and I would like to learn more. I'm using SAS 9.4 on windows, here's my code and results:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*using the cars dataset from sashelp;
data cars; set sashelp.cars;
run;

*this is one of the normal ways I would create a flag for specific values in the variable MAKE;
data cars; set cars;
flag=make in ("Acura" "Mazda" "Toyota");
run;


*This is the new way that I found to make a flag for specific values in the variable MAKE;
*the best way I can describe it - placing the variable name as the first term creates an array;&lt;BR /&gt;*that the rest of the IN statement searches over for the remaining terms;
data cars; set cars;
flag2=0;
if in (strip(make),"Acura","Mazda","Toyota") then flag2=1;
run;&lt;BR /&gt;
proc freq data=cars;
table flag*flag2*make/list missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;here are the results from the frequency:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sashelp.png" style="width: 282px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36562i2D657D6193ED04C9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sashelp.png" alt="sashelp.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, flag2 correctly identified the same values as flag. This code seems to work, but I would like to be sure it will work in other situations by reviewing the documentation. Again, I have been searching online without any success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone else used this syntax or found any documentation? Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 21:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629280#M20729</guid>
      <dc:creator>pcohen</dc:creator>
      <dc:date>2020-03-03T21:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for documentation on why IF IN over variable "array" works</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629320#M20730</link>
      <description>&lt;P&gt;Interesting and apparently undocumented feature that a list of &lt;STRONG&gt;comma delimited character&lt;/STRONG&gt; values will compare the first value to the remaining.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this code:&lt;/P&gt;
&lt;PRE&gt;data work.cars;
   set sashelp.cars;
   flag = in ( strip(make), "Acura","Mazda","Toyota" ) ;
   flag4= in (  "Acura","Mazda","Toyota",strip(make) ) ;
/*   flag2 = in ( strip(make) "Acura" "Mazda" "Toyota" ) ;*/
   flag3 = in ( cylinders, 4, 6);
run;&lt;/PRE&gt;
&lt;P&gt;Flag behaves as your example. Flag4 gets set to 1&amp;nbsp;only when Make is Acura. Flag2, if uncommented, creates an error about expected operator or function&lt;/P&gt;
&lt;PRE&gt;1746     flag2 = in ( strip(make) "Acura" "Mazda" "Toyota" ) ;
                                  -------
                                  22
                                  200
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, ), *, **, +, ',', -, /, &amp;lt;,
              &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT,
              NOTIN, OR, ^, ^=, |, ||, ~, ~=.

ERROR 200-322: The symbol is not recognized and will be ignored.

&lt;/PRE&gt;
&lt;P&gt;and Flag4 generates&lt;/P&gt;
&lt;PRE&gt;NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
&lt;/PRE&gt;
&lt;P&gt;referencing the positions of Cylinders, the 4 and the 6 and the flag is set to one when matching.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am wondering if we are getting a side effect of the in operator requires a single value before the IN and all the values get pushed into a stack. So when no value precedes the operator the first element of the stack is missing but the compiler evaluates the remaining items. But the character only is interesting.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 23:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629320#M20730</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-03-03T23:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for documentation on why IF IN over variable "array" works</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629323#M20731</link>
      <description>&lt;P&gt;Your first flag is an example of a numeric boolean expression as documented here:&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p00iah2thp63bmn1lt20esag14lh.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p084fxdgd12w4sn1o2xivbvaxmx8&amp;nbsp;" target="_blank"&gt;https://documentation.sas.com/?docsetId=lrcon&amp;amp;docsetTarget=p00iah2thp63bmn1lt20esag14lh.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p084fxdgd12w4sn1o2xivbvaxmx8&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 23:17:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629323#M20731</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-03-03T23:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for documentation on why IF IN over variable "array" works</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629325#M20733</link>
      <description>&lt;P&gt;Thanks for replying. To be clear, the first flag is not the one I am asking about, it's the second one (flag2).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As it shows in the documentation you provided, the syntax is that the variable needs to be placed after the "if" and before the "in":&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if state in ('NY','NJ','PA')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For whatever reason, that is not always the case and the variable can be placed inside the parenthesis while still producing the same results. I'm trying to understand why this code works:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if in (strip(state),'NY','NJ','PA')&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 23:27:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629325#M20733</guid>
      <dc:creator>pcohen</dc:creator>
      <dc:date>2020-03-03T23:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for documentation on why IF IN over variable "array" works</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629326#M20734</link>
      <description>&lt;P&gt;Thanks for looking into this! What you've explained makes sense - the comma delimited character values compare the first value to the remaining. You can also list multiple variables instead of one variable and multiple values and get the same outcome.&lt;/P&gt;&lt;P&gt;Unless there are other uses for this feature, I do not see how it will be any more useful than other features as it is more challenging to use. I found that if I did not strip the variable within the statement, it was unable to locate values of shorter lengths, but if I added trailing blanks to the values it would work. Very strange feature.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 23:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629326#M20734</guid>
      <dc:creator>pcohen</dc:creator>
      <dc:date>2020-03-03T23:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for documentation on why IF IN over variable "array" works</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629360#M20738</link>
      <description>&lt;P&gt;The second usage of "in" indicates, that a function named "in" exists, returning the very same result as the in-operator.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 06:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629360#M20738</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-03-04T06:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for documentation on why IF IN over variable "array" works</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629383#M20742</link>
      <description>&lt;P&gt;This looks like an undocumented function. Bring this to the attention of SAS Technical Support, so that the documentation is updated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While the in operator automatically strips the argument to the left, the function needs the "manual" strip.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 09:04:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-documentation-on-why-IF-IN-over-variable-quot-array/m-p/629383#M20742</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-03-04T09:04:42Z</dc:date>
    </item>
  </channel>
</rss>

