<?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: First/Last Statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670370#M201223</link>
    <description>&lt;PRE&gt;First.ParkName=1 and Last.ParkName=1 then output&lt;/PRE&gt;
&lt;P&gt;This produces a record that is outputted only when there is only one record for that parkname (in other words, when both first.parkname and last.parkname are true for the same record).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The explanation you stated "If we combine those two statement together, thus the unique name will be duplicate, which occur twice in the output table" is not what will happen from this code. It would happen if the code were&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
First.ParkName=1 OR Last.ParkName=1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and there were multiple records for that parkname, then you would get two record for that parkname.&lt;/P&gt;</description>
    <pubDate>Sat, 18 Jul 2020 19:56:26 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-07-18T19:56:26Z</dc:date>
    <item>
      <title>First/Last Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670366#M201220</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am currently studying course Programming 2. In lesson (summarizing data), challenge practice. I am confused about code:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;if First.ParkName=1 and Last.ParkName=1 
        then output singleState;
    else output multiState;&lt;/PRE&gt;&lt;P&gt;The question and answer are following:&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;For my understanding, first.parkname=1 means the first occurrence of one unique parkname,&amp;nbsp;&amp;nbsp;last.parkname=1&amp;nbsp;means the last occurrence of that unique parkname. If we want create a table with unique parkname, we need to use fist.parkname=1 to collect all unique name. If we combine those two statement together, thus the unique name will be duplicate, which occur twice in the output table. Here is my concerns. Please help to figure out my confusion. Thanks so much.&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 19:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670366#M201220</guid>
      <dc:creator>Jianan_luna</dc:creator>
      <dc:date>2020-07-18T19:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: First/Last Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670370#M201223</link>
      <description>&lt;PRE&gt;First.ParkName=1 and Last.ParkName=1 then output&lt;/PRE&gt;
&lt;P&gt;This produces a record that is outputted only when there is only one record for that parkname (in other words, when both first.parkname and last.parkname are true for the same record).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The explanation you stated "If we combine those two statement together, thus the unique name will be duplicate, which occur twice in the output table" is not what will happen from this code. It would happen if the code were&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
First.ParkName=1 OR Last.ParkName=1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and there were multiple records for that parkname, then you would get two record for that parkname.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 19:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670370#M201223</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-18T19:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: First/Last Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670379#M201231</link>
      <description>&lt;P&gt;Thanks so much sir. I still have one question, what if I use Last.parkname=1(or first.name=1) only to get the unique name for that column. Because we want to record the occurrence of unique name of parkname column, both the single statement can record the occurrence once it equal to 1. I run the code, the answer is different, can u please explain it?&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 20:27:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670379#M201231</guid>
      <dc:creator>Jianan_luna</dc:creator>
      <dc:date>2020-07-18T20:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: First/Last Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670381#M201232</link>
      <description>&lt;P&gt;Looking at the original code, it was creating two data sets, SINGLESTATE and MULTISTATE. Parknames that appear once get output to SINGLESTATE and parknames that appear more than once are output to MULTISTATE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you are proposing (use only last.parkname) ignores that we are trying to get two data sets, and its not clear what you mean. Please show a complete data step to make your question more clear.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jul 2020 20:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670381#M201232</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-18T20:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: First/Last Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670418#M201249</link>
      <description>&lt;P&gt;Below example shows you when first.&amp;lt;variable&amp;gt; and last.&amp;lt;variable&amp;gt; gets a value of 1 (TRUE) or value of 0 (FALSE).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1595122650123.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47296i3E31E20E0F2649E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1595122650123.png" alt="Patrick_0-1595122650123.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;If you want to select rows from a sorted source table where there is only a single row in a by group then you need to use IF first.&amp;lt;variable&amp;gt; AND last.&amp;lt;variable&amp;gt;. That's the logic which will select the row where ParkName is BBB in above sample.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jul 2020 01:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-Last-Statement/m-p/670418#M201249</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-07-19T01:43:42Z</dc:date>
    </item>
  </channel>
</rss>

