<?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 Adding ONE new observation. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-ONE-new-observation/m-p/76072#M16415</link>
    <description>If the table looks like this, with 2 variables; Id and Amount:&lt;BR /&gt;
&lt;BR /&gt;
Id Amount&lt;BR /&gt;
Q 1200&lt;BR /&gt;
W 1500&lt;BR /&gt;
E 1100&lt;BR /&gt;
&lt;BR /&gt;
I would like to add one new "observation" to the table. The new "observation" should have the values:&lt;BR /&gt;
&lt;BR /&gt;
Id = Sum&lt;BR /&gt;
Amount = 3800&lt;BR /&gt;
&lt;BR /&gt;
I have my reasons to have the sum as an observation in the table.&lt;BR /&gt;
&lt;BR /&gt;
Could this be achieved with code?</description>
    <pubDate>Tue, 03 Mar 2009 10:22:37 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-03-03T10:22:37Z</dc:date>
    <item>
      <title>Adding ONE new observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-ONE-new-observation/m-p/76072#M16415</link>
      <description>If the table looks like this, with 2 variables; Id and Amount:&lt;BR /&gt;
&lt;BR /&gt;
Id Amount&lt;BR /&gt;
Q 1200&lt;BR /&gt;
W 1500&lt;BR /&gt;
E 1100&lt;BR /&gt;
&lt;BR /&gt;
I would like to add one new "observation" to the table. The new "observation" should have the values:&lt;BR /&gt;
&lt;BR /&gt;
Id = Sum&lt;BR /&gt;
Amount = 3800&lt;BR /&gt;
&lt;BR /&gt;
I have my reasons to have the sum as an observation in the table.&lt;BR /&gt;
&lt;BR /&gt;
Could this be achieved with code?</description>
      <pubDate>Tue, 03 Mar 2009 10:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-ONE-new-observation/m-p/76072#M16415</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-03T10:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Adding ONE new observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-ONE-new-observation/m-p/76073#M16416</link>
      <description>No problem.&lt;BR /&gt;
&lt;BR /&gt;
data add_ob;&lt;BR /&gt;
*use the end=last to tell us when we have reached the last observation;&lt;BR /&gt;
set original end=last;&lt;BR /&gt;
*output every observation we have already;&lt;BR /&gt;
output;&lt;BR /&gt;
*and when we have output the last original;&lt;BR /&gt;
if last then do;&lt;BR /&gt;
*create the values;&lt;BR /&gt;
Id='Sum';&lt;BR /&gt;
Amount=3800;&lt;BR /&gt;
*and output another observation;&lt;BR /&gt;
output;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Job done.</description>
      <pubDate>Tue, 03 Mar 2009 10:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-ONE-new-observation/m-p/76073#M16416</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-03T10:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Adding ONE new observation.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-ONE-new-observation/m-p/76074#M16417</link>
      <description>I think the point is to calculate the sum.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
   input Id:$1. Amount;&lt;BR /&gt;
   cards;&lt;BR /&gt;
Q 1200&lt;BR /&gt;
W 1500&lt;BR /&gt;
E 1100&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
data sum;&lt;BR /&gt;
   length ID $3; * "Sum" won't fit in $1;&lt;BR /&gt;
   do while(not eof);&lt;BR /&gt;
      set have end=eof;&lt;BR /&gt;
      output;&lt;BR /&gt;
      sum + amount;&lt;BR /&gt;
      end;&lt;BR /&gt;
   id     = 'Sum';&lt;BR /&gt;
   amount = sum;&lt;BR /&gt;
   output;&lt;BR /&gt;
   stop;&lt;BR /&gt;
   drop sum;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 03 Mar 2009 11:00:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-ONE-new-observation/m-p/76074#M16417</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-03-03T11:00:42Z</dc:date>
    </item>
  </channel>
</rss>

