<?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. statement within groups in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-statement-within-groups/m-p/78355#M288141</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Data out; &lt;/P&gt;&lt;P&gt;set in;&lt;/P&gt;&lt;P&gt;by social_security_number year;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;first.name &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Sep 2013 07:10:02 GMT</pubDate>
    <dc:creator>SteffenBille</dc:creator>
    <dc:date>2013-09-11T07:10:02Z</dc:date>
    <item>
      <title>first. and last. statement within groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-statement-within-groups/m-p/78353#M288139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is it possible to use the first. and last. statement within certain groups?&lt;/P&gt;&lt;P&gt;E.g. I have a variable with social security numbers and a variable with years. I have multiple person records each year. I would like to use the first. statement to identify the first observation of each social security number, but for each year. Is this possible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 06:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-and-last-statement-within-groups/m-p/78353#M288139</guid>
      <dc:creator>AndreasKirk</dc:creator>
      <dc:date>2013-09-11T06:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: first. and last. statement within groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-statement-within-groups/m-p/78354#M288140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Short answer: yes ....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n01a08zkzy5igbn173zjz82zsi1s.htm" title="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n01a08zkzy5igbn173zjz82zsi1s.htm"&gt;SAS(R) 9.3 Language Reference: Concepts, Second Edition&lt;/A&gt; (How the DATA Step Identifies BY Groups)&lt;/P&gt;&lt;P&gt;An example is mot easy found bit it works (long time ago remembering having done)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 06:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-and-last-statement-within-groups/m-p/78354#M288140</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2013-09-11T06:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: first. and last. statement within groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-statement-within-groups/m-p/78355#M288141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Data out; &lt;/P&gt;&lt;P&gt;set in;&lt;/P&gt;&lt;P&gt;by social_security_number year;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;first.name &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 07:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-and-last-statement-within-groups/m-p/78355#M288141</guid>
      <dc:creator>SteffenBille</dc:creator>
      <dc:date>2013-09-11T07:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: first. and last. statement within groups</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-and-last-statement-within-groups/m-p/78356#M288142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Corrected version&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data out;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set in;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by social_security_number year;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;if first.year&lt;/STRONG&gt; then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Explanation&lt;/P&gt;&lt;P&gt;You can have numerous by variables, and for each one first and last automatic variables are generated.&lt;/P&gt;&lt;P&gt;In this case first.social_security_number would return only one record per social_security_number.&amp;nbsp; First.year is updated every time there is a change in the preceding by variable(s) as well as when there is a change in year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Sep 2013 07:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-and-last-statement-within-groups/m-p/78356#M288142</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-09-11T07:24:50Z</dc:date>
    </item>
  </channel>
</rss>

