<?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: how to calculate sum and replace it in missing value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-and-replace-it-in-missing-value/m-p/405909#M98776</link>
    <description>&lt;P&gt;Whilst&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has given you the answer, I would step back one and ask why you have a dataset which looks like that in the first place.&amp;nbsp; How have you added "Total" without adding the sum in at the same time, seems like the step before needs changing.&amp;nbsp; You can add totals on in various ways, my first thought was:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  *
  from    HAVE
  union all
  select  "Total",
          sum(N) 
  from    HAVE;
quit;&lt;/PRE&gt;
&lt;P&gt;Simply adds a row at the end of the dataset with total.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Oct 2017 09:31:51 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-10-20T09:31:51Z</dc:date>
    <item>
      <title>how to calculate sum and replace it in missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-and-replace-it-in-missing-value/m-p/405898#M98772</link>
      <description>&lt;P&gt;I have a dataset as below&lt;/P&gt;&lt;P&gt;PT&amp;nbsp; &amp;nbsp; &amp;nbsp;N&lt;/P&gt;&lt;P&gt;102&amp;nbsp; &amp;nbsp;25&lt;/P&gt;&lt;P&gt;103&amp;nbsp; &amp;nbsp;34&lt;/P&gt;&lt;P&gt;Total&amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to replace the missing with the sum of the 2 counts in N. Can i do that in datastep?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 09:08:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-and-replace-it-in-missing-value/m-p/405898#M98772</guid>
      <dc:creator>mj5</dc:creator>
      <dc:date>2017-10-20T09:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate sum and replace it in missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-and-replace-it-in-missing-value/m-p/405905#M98775</link>
      <description>&lt;P&gt;You can retain a variable where you sum up all N values, and when PT = 'Total', you set N to that value.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 09:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-and-replace-it-in-missing-value/m-p/405905#M98775</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-20T09:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate sum and replace it in missing value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-and-replace-it-in-missing-value/m-p/405909#M98776</link>
      <description>&lt;P&gt;Whilst&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has given you the answer, I would step back one and ask why you have a dataset which looks like that in the first place.&amp;nbsp; How have you added "Total" without adding the sum in at the same time, seems like the step before needs changing.&amp;nbsp; You can add totals on in various ways, my first thought was:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  *
  from    HAVE
  union all
  select  "Total",
          sum(N) 
  from    HAVE;
quit;&lt;/PRE&gt;
&lt;P&gt;Simply adds a row at the end of the dataset with total.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 09:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-and-replace-it-in-missing-value/m-p/405909#M98776</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-20T09:31:51Z</dc:date>
    </item>
  </channel>
</rss>

