<?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: if &amp;amp; where statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699734#M214056</link>
    <description>so basically , whatever i will write above where ?? it won't take that condition in observation ?</description>
    <pubDate>Wed, 18 Nov 2020 10:51:36 GMT</pubDate>
    <dc:creator>librasonali</dc:creator>
    <dc:date>2020-11-18T10:51:36Z</dc:date>
    <item>
      <title>if &amp; where statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699719#M214053</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;BR /&gt;I have a doubt in the &lt;STRONG&gt;number of observations .&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;question :&amp;nbsp;create a temporary data set, cleandata36.&lt;BR /&gt;In this data set, convert all group values to upper case.&lt;BR /&gt;Then keep only observations with group equal to 'A' or 'B'.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when I run&amp;nbsp; below code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data cleandata36;&lt;BR /&gt;set cert.input36 ;&lt;BR /&gt;if upcase(group) in ('A','B');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then number of observations are different&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but when I run&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data cleandata36;&lt;BR /&gt;set cert.input36 ;&lt;BR /&gt;&lt;STRONG&gt;group=upcase(group);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;where group in ('A','B');&lt;/STRONG&gt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the number of observations are different.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but the logic I want to implement is maybe same. Can please anyone tell me that why there is mismatch of observations &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 09:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699719#M214053</guid>
      <dc:creator>librasonali</dc:creator>
      <dc:date>2020-11-18T09:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: if &amp; where statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699721#M214054</link>
      <description>&lt;P&gt;The WHERE statement is applied to the input dataset, and therefore to the raw values. To make it work, use the function in the statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where upcase(group) in ('A','B');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Nov 2020 09:46:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699721#M214054</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-18T09:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: if &amp; where statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699722#M214055</link>
      <description>&lt;P&gt;The &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=n1xbr9r0s9veq0n137iftzxq4g7e.htm&amp;amp;locale=en" target="_self"&gt;Where Statement&lt;/A&gt; is a compile-time statement. It controls what observations are being read into the data step. Meaning that in the code below, it considers the values read - NOT the upcased values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p1cxl8ifdt8u0gn12wqbji8o5fq1.htm&amp;amp;locale=en" target="_self"&gt;Subsetting If Statement&lt;/A&gt; is considered at run-time. Therefore, in the code below, it considers the upcased values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this makes sense &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input group :$1;
datalines;
A
a
B
b
; 

data test1;
   set have;
   group = upcase(group);
   where group in ('A', 'B');
run;

data test2;
   set have;
   group = upcase(group);
   if group in ('A', 'B');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 09:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699722#M214055</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-18T09:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: if &amp; where statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699734#M214056</link>
      <description>so basically , whatever i will write above where ?? it won't take that condition in observation ?</description>
      <pubDate>Wed, 18 Nov 2020 10:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699734#M214056</guid>
      <dc:creator>librasonali</dc:creator>
      <dc:date>2020-11-18T10:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: if &amp; where statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699738#M214057</link>
      <description>&lt;P&gt;The position of a WHERE statement in the code is irrelevant, as it is applied in the read engine for the incoming dataset. A WHERE statement has the same function that a WHERE= dataset option has, and in a certain sense you can consider it to work "outside" the data step.&lt;/P&gt;
&lt;P&gt;I also recommend that you study the documentation of the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=n1xbr9r0s9veq0n137iftzxq4g7e.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;WHERE Statement&lt;/A&gt; thoroughly.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 11:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/if-amp-where-statements/m-p/699738#M214057</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-18T11:21:31Z</dc:date>
    </item>
  </channel>
</rss>

