<?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: WHERE versus IF IN subsetting unexpectedly different in SAS Certification</title>
    <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/887316#M1605</link>
    <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for this.&amp;nbsp; This actually made me really happy to read!&amp;nbsp; Everything I thought I understood became much more of a struggle as I actually try to put it in practice (or answer practice exam questions).&amp;nbsp; So, hearing that I actually "came up with a solution" gives me hope.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":party_popper:"&gt;🎉&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Aug 2023 13:32:24 GMT</pubDate>
    <dc:creator>TheresaM</dc:creator>
    <dc:date>2023-08-01T13:32:24Z</dc:date>
    <item>
      <title>WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886835#M1594</link>
      <description>&lt;P&gt;I understand that WHERE and IF IN can produce different results depending on where each statement is used. However, one of the questions on the (official) SAS 9.4 Certification Practice Exam has me puzzled.&amp;nbsp; The question read:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN class=""&gt;This project will use data set&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;cert.input36&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;.&amp;nbsp;At any time, you may save your program as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;program36&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;cert\programs&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;Write a SAS program that will clean the data in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;cert.input36&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Step 1:&lt;/SPAN&gt;&lt;/LI&gt;&lt;UL&gt;&lt;LI&gt;create a temporary data set,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cleandata36&lt;/STRONG&gt;.&lt;/LI&gt;&lt;LI&gt;In this data set, convert all&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;group&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;values to upper case.&lt;/LI&gt;&lt;LI&gt;Then keep only observations with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;group&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;equal to 'A' or 'B'.&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI&gt;Step 2:&lt;/LI&gt;&lt;UL&gt;&lt;LI&gt;Determine the MEDIAN value for the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Kilograms&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;variable for each&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;group&lt;/STRONG&gt;&amp;nbsp;(A,B) in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cleandata36&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;data set. Round MEDIAN to the nearest whole number.&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI&gt;Step 3:&lt;/LI&gt;&lt;UL&gt;&lt;LI&gt;create&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;results.output36&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;from&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cleandata36&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Ensure that all values for variable&amp;nbsp;&lt;STRONG&gt;Kilograms&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;are between 40 and 200, inclusively.&lt;/LI&gt;&lt;LI&gt;If the value is missing or out of range, replace the value with the MEDIAN&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Kilograms&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;value for the respective&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;group&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(A,B) calculated in step 2.&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Run the program and use the results to answer the next 3 questions.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Their suggested code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.cleandata36;
   set cert.input36;
   group=upcase(group);
   if group in ('A','B');
run;

proc means data=work.cleandata36 median;
  class group;
  var kilograms;
run;

data results.output36;
  set cleandata36;
  if Kilograms &amp;lt; 40 or Kilograms &amp;gt; 200 then do;
    if group='A' then kilograms=79;
    else kilograms=89;
  end;
run;

proc contents data=results.output36;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data work.cleandata36;
	set cert.input36;
	group = upcase(group);
	where group = 'A' or group = 'B';
run;

proc means data=work.cleandata36 mean min max median maxdec=1;
	class group;
run;

data results.output36;
	set cleandata36;
	if kilograms &amp;lt; 40 or kilograms &amp;gt; 200 then do;
		if group = 'A' then kilograms = 79;
		else kilograms = 89;
	end;
	if kilograms =. then do;
		if group = 'A' then kilograms = 79;
		else kilograms = 89;
	end;
run;
	
proc print data = results.output36;
run;

proc means data=results.output36 mean min max maxdec=1;
	class group;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached input36.sas7bdate in case anyone wanted to test.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When asked how many observations are in results.output36, my code (with the WHERE statement)&amp;nbsp; resulted in 4897 observations.&amp;nbsp; This was wrong, as their code (using IF IN) resulted in 4992.&amp;nbsp; I tested my code using IF IN instead of WHERE and got the same result they did, 4992. But I'm not sure why. It would seem that both statements would subset to the same number of observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also,&amp;nbsp; their code is missing the portion that accounts for the instruction to &lt;FONT face="helvetica"&gt;&lt;STRONG&gt;replace missing values&lt;/STRONG&gt; &lt;/FONT&gt;with the median -- I'm surprised they wouldn't include it in their suggested answer.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 16:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886835#M1594</guid>
      <dc:creator>TheresaM</dc:creator>
      <dc:date>2023-07-28T16:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886843#M1595</link>
      <description>&lt;P&gt;IF and WHERE in a data step work differently. This is explained in the documentation:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsref/p1cxl8ifdt8u0gn12wqbji8o5fq1.htm#p08fp02gyb04apn1fmq0a6cu3ynd" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsref/p1cxl8ifdt8u0gn12wqbji8o5fq1.htm#p08fp02gyb04apn1fmq0a6cu3ynd&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 17:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886843#M1595</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-28T17:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886851#M1596</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446221"&gt;@TheresaM&lt;/a&gt;&amp;nbsp;Here is a bit more of a hint: Notice this bullet from step 1:&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;In this data set, convert all group values to upper case.&lt;/EM&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Then learn the difference between how IF and WHERE process data using the resource from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;and I think you will see why your code produces a different result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 17:08:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886851#M1596</guid>
      <dc:creator>Mark2010</dc:creator>
      <dc:date>2023-07-28T17:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886852#M1597</link>
      <description>&lt;P&gt;Hi Paige,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought I understood all those differences as outlined in the page you reference. However, the way I read all that -- it would seem that my use of WHERE would produce the larger subset (since it selects observations before they're brought into PDV), yet somehow IF IN subsetted a larger number of observations.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 17:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886852#M1597</guid>
      <dc:creator>TheresaM</dc:creator>
      <dc:date>2023-07-28T17:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886854#M1598</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38931"&gt;@Mark2010&lt;/a&gt;&amp;nbsp;.&amp;nbsp; I'll take some more time to understand the documentation!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 17:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886854#M1598</guid>
      <dc:creator>TheresaM</dc:creator>
      <dc:date>2023-07-28T17:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886883#M1599</link>
      <description>&lt;P&gt;One way to explore this is to make a small test dataset, like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data play ;
  input group $1. ;
  cards ;
A
B
C
D
.
a
b
c
d
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you could use that as an input to your WHERE data step and your subsetting IF data step and see how the results differ.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 18:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886883#M1599</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-07-28T18:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886884#M1600</link>
      <description>&lt;P&gt;ah!&amp;nbsp; It took me few times rereading the documentation, but I think light finally dawned:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WHERE subsetted the data before UPCASE happened ("&lt;SPAN&gt;The WHERE statement selects observations before they are brought into the program data vector.&amp;nbsp;")&lt;/SPAN&gt;, and so even though I changed all values of "group" to upper case, it happened after WHERE selected its observations.&amp;nbsp; Thus, my WHERE subset is smaller because it didn't have access to all the instances of "group" where 'a' and 'b' had been converted to upper case.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 18:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886884#M1600</guid>
      <dc:creator>TheresaM</dc:creator>
      <dc:date>2023-07-28T18:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886885#M1601</link>
      <description>&lt;P&gt;Bingo. Congrats on working through it.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 18:33:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886885#M1601</guid>
      <dc:creator>Mark2010</dc:creator>
      <dc:date>2023-07-28T18:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886886#M1602</link>
      <description>&lt;P&gt;You got it.&amp;nbsp; So you could use WHERE, like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where upcase(group) = 'A' or upcase(group) = 'B';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where upcase(group) IN ('A' , 'B');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And it would select the same records as your IF.&amp;nbsp; &amp;nbsp;You would still need to use UPCASE inside the data step to upcase the values.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 18:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886886#M1602</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-07-28T18:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886893#M1603</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446221"&gt;@TheresaM&lt;/a&gt;&amp;nbsp;I suggest you select your own answer as the solution.&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/38931"&gt;@Mark2010&lt;/a&gt;&amp;nbsp;gave you a good hint, but you came up with the solution and wrote it as an answer.&amp;nbsp; You also did a good job of phrasing the question clearly, and showing sample code.&amp;nbsp; So if anyone finds it in the future, it would be good for them to see your answer as the solution.&amp;nbsp; You should be able to click on Mark's answer and see an option to "unmark as correct" or something like that.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jul 2023 19:20:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/886893#M1603</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-07-28T19:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/887000#M1604</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446221"&gt;@TheresaM&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know this is a (very) lagged response.&amp;nbsp; &amp;nbsp;But ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I find it most useful to regard the WHERE statement (or where option as a dataset name parameter) as a &lt;EM&gt;&lt;STRONG&gt;process outsourced to the data engine&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's why WHERE can be used in PROC's as well as DATA steps - unlike IF.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 15:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/887000#M1604</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-08-07T15:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/887316#M1605</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for this.&amp;nbsp; This actually made me really happy to read!&amp;nbsp; Everything I thought I understood became much more of a struggle as I actually try to put it in practice (or answer practice exam questions).&amp;nbsp; So, hearing that I actually "came up with a solution" gives me hope.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":party_popper:"&gt;🎉&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Aug 2023 13:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/887316#M1605</guid>
      <dc:creator>TheresaM</dc:creator>
      <dc:date>2023-08-01T13:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/888137#M1608</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for this too!&amp;nbsp; Where vs IF, when to use the = sign vs when not to, DO while vs DO until... so much to remember!!&amp;nbsp; I know it will become easier to remember the more programs that I write, but until then, every tip helps.&amp;nbsp; So thanks for responding to my post &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 14:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/888137#M1608</guid>
      <dc:creator>TheresaM</dc:creator>
      <dc:date>2023-08-07T14:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE versus IF IN subsetting unexpectedly different</title>
      <link>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/970025#M1877</link>
      <description>&lt;P&gt;Use IF when you need to filter based on new or transformed variables.&lt;BR /&gt;Use WHERE when filtering on existing dataset variables, and in PROC steps, for better efficiency.&lt;/P&gt;&lt;P&gt;note:&lt;BR /&gt;With IF, this upcase() runs before filtering, so lowercase “a” and “b” are converted, then kept.&lt;BR /&gt;With WHERE, the condition is evaluated before upcase(). Since it checks the original values, lowercase “a” or “b” will not match and get dropped.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's why you get different obs number with where and if.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;incase of missing data-&lt;/P&gt;&lt;P&gt;data results.output36;&lt;BR /&gt;set cleandata36;&lt;BR /&gt;if Kilograms = '.' or 40&amp;gt;Kilograms or Kilograms&amp;gt;200 then do;&lt;BR /&gt;if group='A' then Kilograms=79;&lt;BR /&gt;else Kilograms=89;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jul 2025 10:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Certification/WHERE-versus-IF-IN-subsetting-unexpectedly-different/m-p/970025#M1877</guid>
      <dc:creator>DBsky</dc:creator>
      <dc:date>2025-07-01T10:11:57Z</dc:date>
    </item>
  </channel>
</rss>

