<?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. and last. usage in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357018#M83775</link>
    <description>&lt;P&gt;The net effect: &amp;nbsp;any ID values that have just a single observation get deleted. &amp;nbsp;It's a topic that is well worth studying. &amp;nbsp;Here is one place to start:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/forum2007/222-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/222-2007.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to read a few background pages before it gets to the point of adding the BY statement in the DATA step.&lt;/P&gt;</description>
    <pubDate>Mon, 08 May 2017 20:44:37 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-05-08T20:44:37Z</dc:date>
    <item>
      <title>first. and last. usage in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357012#M83772</link>
      <description>&lt;P&gt;Hi All:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could some one explain first.variable and last. variable concept for me ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg: the data ids2 has been sorted using proc sort,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dupes;&lt;BR /&gt;set ids2;&lt;BR /&gt;by id;&lt;BR /&gt;&lt;STRONG&gt;if not (first.id and last.id) then output;&lt;/STRONG&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if not (first.id and last.id) then output; &amp;nbsp;--&amp;gt; what doest this code do?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there a paper about first. and last. usage in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 20:26:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357012#M83772</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-05-08T20:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: first. and last. usage in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357015#M83773</link>
      <description>&lt;P&gt;I would recommend starting with the documentation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#n138da4gme3zb7n1nifpfhqv7clq.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#n138da4gme3zb7n1nifpfhqv7clq.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The section related to First/Last is under the section titled:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How the DATA Step Identifies BY Groups&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 20:44:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357015#M83773</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-08T20:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: first. and last. usage in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357016#M83774</link>
      <description>This means if first. and last. isn't the same observation then output. This will be true for all observations in a BY group with more than one observation. &lt;BR /&gt;There are tons of papers. Search support.sas.com and global forum proceedings as a start.</description>
      <pubDate>Mon, 08 May 2017 20:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357016#M83774</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-05-08T20:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: first. and last. usage in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357018#M83775</link>
      <description>&lt;P&gt;The net effect: &amp;nbsp;any ID values that have just a single observation get deleted. &amp;nbsp;It's a topic that is well worth studying. &amp;nbsp;Here is one place to start:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www2.sas.com/proceedings/forum2007/222-2007.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2007/222-2007.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to read a few background pages before it gets to the point of adding the BY statement in the DATA step.&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 20:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357018#M83775</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-08T20:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: first. and last. usage in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357020#M83776</link>
      <description>&lt;P&gt;You said it was sorted, I'll presume it was sorted by id.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case, using ID as the by variable, first.id will be equal to 1 when, and only when, it is the first record for that ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly, last.id&amp;nbsp;&lt;SPAN&gt;will be equal to 1 when, and only when, it is the last&amp;nbsp;record for that ID.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;As such, think about the statement you asked about:&amp;nbsp;&lt;STRONG&gt;if not (first.id and last.id) then output;&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It's opposite&amp;nbsp;&lt;STRONG&gt;if &amp;nbsp;(first.id and last.id) then output; &amp;nbsp;&lt;/STRONG&gt;would only output records where there was only one record for an ID. For any IDs that had multiple records, it would never be true for any of the records. As such,&amp;nbsp;&lt;STRONG&gt;if not (first.id and last.id) then output;&amp;nbsp;&lt;/STRONG&gt;will output all records where there ARE multiple records for a given ID.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Art, CEO, AnalystFinder.com&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 20:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357020#M83776</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-08T20:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: first. and last. usage in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357021#M83777</link>
      <description>&lt;P&gt;A big thanks to all the following people&lt;/P&gt;&lt;P&gt;LinusH, Reeza, Astounding &amp;amp; art297.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;The explanantion certainly helped me understand the concept. Thanks a lot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2017 20:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-and-last-usage-in-sas/m-p/357021#M83777</guid>
      <dc:creator>buddha_d</dc:creator>
      <dc:date>2017-05-08T20:51:13Z</dc:date>
    </item>
  </channel>
</rss>

