<?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/IF UPCASE() in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745937#M29400</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for your time and explanation with this. Definitely understand now!&lt;/P&gt;</description>
    <pubDate>Fri, 04 Jun 2021 22:07:51 GMT</pubDate>
    <dc:creator>JC411911</dc:creator>
    <dc:date>2021-06-04T22:07:51Z</dc:date>
    <item>
      <title>WHERE/IF UPCASE()</title>
      <link>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745673#M29388</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am preparing for the base certification and hoping I can get some help understanding this question I have gotten wrong a few times. The first step is a pretty basic ask but I got it wrong because I am using if rather than when.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Write a SAS program that will clean the data in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cert.input36&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as follows:&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;P&gt;Below is what I wrote:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA CLEANDATA36;
	SET CERT.INPUT36;
	GROUP=UPCASE(GROUP);
	WHERE GROUP IN ('A', 'B');
RUN;

PROC MEANS DATA=CLEANDATA36 MEDIAN;
	VAR KILOGRAMS;
	CLASS GROUP;&lt;BR /&gt;RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get it wrong but change the where to IF and get it correct can anyone help me understand this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;While the code works the question is how many observations are there after this step, the correct answer being 4992. With the where clause I get 4897.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 03:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745673#M29388</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2021-06-04T03:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE/IF UPCASE()</title>
      <link>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745674#M29389</link>
      <description>&lt;P&gt;Using the where clause, the condition will be applied when reading the dataset.&lt;BR /&gt;Therefore, upcase is not applied to this condition.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;If you use the if clause, the condition will be evaluated as described after the dataset is loaded.&lt;/P&gt;
&lt;P&gt;In other words, upcase will be applied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The input36 dataset has 95 observations that contain the values "a" or "b" in lowercase, so there is a difference in the results between where and if.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 03:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745674#M29389</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-06-04T03:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE/IF UPCASE()</title>
      <link>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745675#M29390</link>
      <description>&lt;P&gt;WHERE filters the data set before it's read in. If you had a value of "a" in the original data set it wouldn't get filtered out.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best way to figure this is out is to test it!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data group_data;
input group $;
cards;
a
A
a
b
a
a
C
B
c
d
a 
G
  B
  A
A
;;;;
run;

title 'Example WHERE';
data example1;
set group_data;
group = upcase(group);
where group in ('A', 'B');
run;
proc print data=example1;run;

title 'Example IF';
data example2;
set group_data;
group = upcase(group);
IF group in ('A', 'B');
run;
proc print data=example2;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And notice the output is different!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHERE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Example WHERE
Obs	group
1	A
2	B
3	B
4	A
5	A

&lt;/PRE&gt;
&lt;P&gt;IF:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Obs	group
1	A
2	A
3	A
4	B
5	A
6	A
7	B
8	A
9	B
10	A
11	A&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/371433"&gt;@JC411911&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am preparing for the base certification and hoping I can get some help understanding this question I have gotten wrong a few times. The first step is a pretty basic ask but I got it wrong because I am using if rather than when.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Write a SAS program that will clean the data in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cert.input36&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as follows:&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;P&gt;Below is what I wrote:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA CLEANDATA36;
	SET CERT.INPUT36;
	GROUP=UPCASE(GROUP);
	WHERE GROUP IN ('A', 'B');
RUN;

PROC MEANS DATA=CLEANDATA36 MEDIAN;
	VAR KILOGRAMS;
	CLASS GROUP;&lt;BR /&gt;RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get it wrong but change the where to IF and get it correct can anyone help me understand this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While the code works the question is how many observations are there after this step, the correct answer being 4992. With the where clause I get 4897.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 03:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745675#M29390</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-04T03:38:10Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE/IF UPCASE()</title>
      <link>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745937#M29400</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;for your time and explanation with this. Definitely understand now!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jun 2021 22:07:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745937#M29400</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2021-06-04T22:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: WHERE/IF UPCASE()</title>
      <link>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745938#M29401</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt; !</description>
      <pubDate>Fri, 04 Jun 2021 22:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/WHERE-IF-UPCASE/m-p/745938#M29401</guid>
      <dc:creator>JC411911</dc:creator>
      <dc:date>2021-06-04T22:09:38Z</dc:date>
    </item>
  </channel>
</rss>

