<?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 why &amp;quot; if _n_ =1 or _n_=last;&amp;quot; works but &amp;quot; if _n_ in (1, last);&amp;quot; doesn't? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/why-quot-if-n-1-or-n-last-quot-works-but-quot-if-n-in-1-last/m-p/77129#M16663</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very mush for your inouts!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data good; /*&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;*/&lt;BR /&gt; set sashelp.class nobs=last;&lt;BR /&gt; if _n_ =1 or _n_=last;&lt;BR /&gt;proc print data=good;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data bad; /*:smileyconfused::smileyconfused::smileyconfused:*/&lt;BR /&gt; set sashelp.class nobs=last;&lt;BR /&gt; if _n_ in (1, last);&lt;BR /&gt;proc print data=bad;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Jul 2013 14:52:16 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2013-07-12T14:52:16Z</dc:date>
    <item>
      <title>why " if _n_ =1 or _n_=last;" works but " if _n_ in (1, last);" doesn't?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-quot-if-n-1-or-n-last-quot-works-but-quot-if-n-in-1-last/m-p/77129#M16663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very mush for your inouts!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data good; /*&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;*/&lt;BR /&gt; set sashelp.class nobs=last;&lt;BR /&gt; if _n_ =1 or _n_=last;&lt;BR /&gt;proc print data=good;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data bad; /*:smileyconfused::smileyconfused::smileyconfused:*/&lt;BR /&gt; set sashelp.class nobs=last;&lt;BR /&gt; if _n_ in (1, last);&lt;BR /&gt;proc print data=bad;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jul 2013 14:52:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-quot-if-n-1-or-n-last-quot-works-but-quot-if-n-in-1-last/m-p/77129#M16663</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-07-12T14:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: why " if _n_ =1 or _n_=last;" works but " if _n_ in (1, last);" doesn't?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-quot-if-n-1-or-n-last-quot-works-but-quot-if-n-in-1-last/m-p/77130#M16664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a proposition by &lt;A href="mailto:Chris@NewZealand"&gt;Chris@NewZealand&lt;/A&gt; to provide the ability to use variable names with the IN operator, see&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="active_link" href="https://communities.sas.com/ideas/1356"&gt;https://communities.sas.com/ideas/1356&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jul 2013 15:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-quot-if-n-1-or-n-last-quot-works-but-quot-if-n-in-1-last/m-p/77130#M16664</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2013-07-12T15:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: why " if _n_ =1 or _n_=last;" works but " if _n_ in (1, last);" doesn't?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-quot-if-n-1-or-n-last-quot-works-but-quot-if-n-in-1-last/m-p/77131#M16665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;from In Operator documentation in SAS&lt;/P&gt;&lt;P&gt;&lt;A name="a000675749"&gt;&lt;/A&gt;The IN operator compares a value produced by an expression on the left side of the operator to a &lt;STRONG&gt;list of values&lt;/STRONG&gt; on the right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from nobs= option documentation in SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; creates and names a &lt;STRONG&gt;temporary variable&lt;/STRONG&gt; whose value is usually the total number of observations in the input data set or data sets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the issue is simply that the IN operator only supports value list and not variables. The following will cause an error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a=1; b=2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if a in (a,b) then put "hello world!";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for the exact same reason that the IN operator does not support variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vincent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jul 2013 15:21:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-quot-if-n-1-or-n-last-quot-works-but-quot-if-n-in-1-last/m-p/77131#M16665</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-07-12T15:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: why " if _n_ =1 or _n_=last;" works but " if _n_ in (1, last);" doesn't?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/why-quot-if-n-1-or-n-last-quot-works-but-quot-if-n-in-1-last/m-p/77132#M16666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; nosobad; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; sashelp.class &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;nobs&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=last;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; _x&lt;LI&gt; _1 last (&lt;/LI&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt; &lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; _n_ in _x;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; _:;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jul 2013 15:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/why-quot-if-n-1-or-n-last-quot-works-but-quot-if-n-in-1-last/m-p/77132#M16666</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-07-12T15:48:18Z</dc:date>
    </item>
  </channel>
</rss>

