<?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: upcase function and subsetting in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/upcase-function-and-subsetting/m-p/691100#M210305</link>
    <description>&lt;P&gt;I understand now. Thanks!&lt;/P&gt;</description>
    <pubDate>Mon, 12 Oct 2020 22:53:40 GMT</pubDate>
    <dc:creator>melc</dc:creator>
    <dc:date>2020-10-12T22:53:40Z</dc:date>
    <item>
      <title>upcase function and subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/upcase-function-and-subsetting/m-p/691094#M210301</link>
      <description>&lt;P&gt;A question in the SAS Certification Practice Programming Performance-Based Exam, requires the use of the upcase function under the condition of subsetting the data set with the values of 'A' or 'B' from the variable called group. A part of the question is to find the number of observations that result from the program. I have listed some programs below and I would like to know why program #3 does not give the same results as #1, #2, and #4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The answer that SAS provided which results in 4992 observations:&lt;BR /&gt;data cleandata;&lt;BR /&gt;set cert.input36;&lt;BR /&gt;if upcase(group) in('A', 'B');&lt;BR /&gt;run;&lt;/LI&gt;&lt;LI&gt;It appears that instead of using 'if', 'where' can provide the same result of 4992 observations:&lt;BR /&gt;data cleandata;&lt;BR /&gt;set cert.input36;&lt;BR /&gt;where upcase(group) in('A', 'B');run;&lt;/LI&gt;&lt;LI&gt;&lt;FONT color="#0000FF"&gt;I thought the following program would result in the correct answer but it doesn't. Why does the following not provide the same results as the two programs above? This has fewer observations&amp;nbsp; than the two programs above. The following results in 4897 observations.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;&lt;SPAN style="font-family: inherit;"&gt;data cleandata;&lt;BR /&gt;set cert.input36;&lt;BR /&gt;group=upcase(group);&lt;BR /&gt;where group in ('A', 'B');&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-family: inherit;"&gt;The following program results in the same number of observations (4992 observations) as the first two programs but it seems to defeat the purpose of using the upcase function because the upcase function can be removed to give the same result&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P class="lia-indent-padding-left-30px"&gt;data cleandata;&lt;BR /&gt;set cert.input36;&lt;BR /&gt;group=upcase(group);&lt;BR /&gt;where group in ('A', 'B', 'a', 'b');&lt;BR /&gt;run;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;OR remove the upcase function since listing all of the possible values with the in operator&amp;nbsp; (4992 observations)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;data cleandata;&lt;BR /&gt;set cert.input36;&lt;BR /&gt;where group in ('A', 'B', 'a', 'b');&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 22:05:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/upcase-function-and-subsetting/m-p/691094#M210301</guid>
      <dc:creator>melc</dc:creator>
      <dc:date>2020-10-12T22:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: upcase function and subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/upcase-function-and-subsetting/m-p/691098#M210303</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/148296"&gt;@melc&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The WHERE statement filters the incoming data immediately (see the note in the log saying "There were ... observations read from data set ... WHERE ..." and also 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#n1t8qo2qlsyhc3n17orioenneykj" target="_self"&gt;documentation&lt;/A&gt;), i.e., other DATA step statements such as the assignment statement &lt;FONT face="courier new,courier"&gt;group=...&lt;/FONT&gt; in the third and fourth program already operate on the subset selected by the WHERE condition (using the GROUP values found in the input dataset), regardless of their position in the DATA step code. Hence, the UPCASE function call in programs 3 and 4 comes too late for the WHERE statement and affects only the outgoing data written to dataset CLEANDATA.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 22:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/upcase-function-and-subsetting/m-p/691098#M210303</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-10-12T22:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: upcase function and subsetting</title>
      <link>https://communities.sas.com/t5/SAS-Programming/upcase-function-and-subsetting/m-p/691100#M210305</link>
      <description>&lt;P&gt;I understand now. Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2020 22:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/upcase-function-and-subsetting/m-p/691100#M210305</guid>
      <dc:creator>melc</dc:creator>
      <dc:date>2020-10-12T22:53:40Z</dc:date>
    </item>
  </channel>
</rss>

