<?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: Write only the last observation. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Write-only-the-last-observation/m-p/8059#M205</link>
    <description>Are you sure?&lt;BR /&gt;
&lt;BR /&gt;
I ran this code and I get an observation at the end.&lt;BR /&gt;
&lt;BR /&gt;
data ds1;&lt;BR /&gt;
input year;&lt;BR /&gt;
cards;&lt;BR /&gt;
1995&lt;BR /&gt;
1996&lt;BR /&gt;
1995&lt;BR /&gt;
1997&lt;BR /&gt;
1996&lt;BR /&gt;
1990&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data DS2;&lt;BR /&gt;
keep year count;&lt;BR /&gt;
set DS1 end=last;&lt;BR /&gt;
if year=1996 then count+1;&lt;BR /&gt;
if last then output;&lt;BR /&gt;
run;</description>
    <pubDate>Wed, 18 Mar 2009 14:37:15 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-03-18T14:37:15Z</dc:date>
    <item>
      <title>Write only the last observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-only-the-last-observation/m-p/8057#M203</link>
      <description>My original SAS data set, DS1, has one variabel, Year.&lt;BR /&gt;
&lt;BR /&gt;
My first code looks like this:&lt;BR /&gt;
&lt;BR /&gt;
data DS2;&lt;BR /&gt;
set DS1;&lt;BR /&gt;
keep year count;&lt;BR /&gt;
if year=1996 then count+1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The program runs and I can check that count has incremented for each year=1996.&lt;BR /&gt;
&lt;BR /&gt;
Then I tried with this code:&lt;BR /&gt;
&lt;BR /&gt;
data DS2;&lt;BR /&gt;
keep year count;&lt;BR /&gt;
set DS1 end=last;&lt;BR /&gt;
if last then output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I expected to have DS2 with one row, and with year value equal to DS1:s last year value and the same value for count as in the first case.&lt;BR /&gt;
But now DS2 has no observations.&lt;BR /&gt;
&lt;BR /&gt;
What's wrong with my code?&lt;BR /&gt;
&lt;BR /&gt;
Anne</description>
      <pubDate>Wed, 18 Mar 2009 13:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-only-the-last-observation/m-p/8057#M203</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-18T13:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Write only the last observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-only-the-last-observation/m-p/8058#M204</link>
      <description>Editing:&lt;BR /&gt;
&lt;BR /&gt;
Then I tried with this code:&lt;BR /&gt;
&lt;BR /&gt;
data DS2;&lt;BR /&gt;
keep year count;&lt;BR /&gt;
set DS1 end=last;&lt;BR /&gt;
if year=1996 then count+1;&lt;BR /&gt;
if last then output;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 18 Mar 2009 14:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-only-the-last-observation/m-p/8058#M204</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-18T14:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Write only the last observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-only-the-last-observation/m-p/8059#M205</link>
      <description>Are you sure?&lt;BR /&gt;
&lt;BR /&gt;
I ran this code and I get an observation at the end.&lt;BR /&gt;
&lt;BR /&gt;
data ds1;&lt;BR /&gt;
input year;&lt;BR /&gt;
cards;&lt;BR /&gt;
1995&lt;BR /&gt;
1996&lt;BR /&gt;
1995&lt;BR /&gt;
1997&lt;BR /&gt;
1996&lt;BR /&gt;
1990&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data DS2;&lt;BR /&gt;
keep year count;&lt;BR /&gt;
set DS1 end=last;&lt;BR /&gt;
if year=1996 then count+1;&lt;BR /&gt;
if last then output;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 18 Mar 2009 14:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-only-the-last-observation/m-p/8059#M205</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-18T14:37:15Z</dc:date>
    </item>
  </channel>
</rss>

