<?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 value for only a few rows of values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-value-for-only-a-few-rows-of-values/m-p/330936#M74323</link>
    <description>&lt;P&gt;Try code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=have(where=(&lt;SPAN&gt;trt in (15,30,37)));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; var ns trt trtc;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; sum ns;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Feb 2017 18:41:11 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-02-08T18:41:11Z</dc:date>
    <item>
      <title>how to calculate sum value for only a few rows of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-value-for-only-a-few-rows-of-values/m-p/330925#M74321</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the following data I need to calculte a sum value for a few OBS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For my data I need to calculate a total value for trt in (15,30,37).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input ns trt $ trtc $;&lt;BR /&gt;datalines;&lt;BR /&gt;20 15 A&lt;BR /&gt;30 30 B&lt;BR /&gt;10 37 C&lt;BR /&gt;50 Place D&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;output needed;&lt;/P&gt;&lt;P&gt;20 15 A&lt;BR /&gt;30 30 B&lt;BR /&gt;10 37 C&lt;BR /&gt;50 Place D&lt;BR /&gt;60 Total E&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 17:41:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-value-for-only-a-few-rows-of-values/m-p/330925#M74321</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-02-08T17:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate sum value for only a few rows of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-value-for-only-a-few-rows-of-values/m-p/330936#M74323</link>
      <description>&lt;P&gt;Try code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=have(where=(&lt;SPAN&gt;trt in (15,30,37)));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; var ns trt trtc;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; sum ns;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 18:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-value-for-only-a-few-rows-of-values/m-p/330936#M74323</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-02-08T18:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate sum value for only a few rows of values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-value-for-only-a-few-rows-of-values/m-p/330943#M74324</link>
      <description>&lt;P&gt;To get a data set that matches your output goal:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have end=done;&lt;/P&gt;
&lt;P&gt;if trt in ('15', '30', '37') then tot_ns + ns;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;if done;&lt;/P&gt;
&lt;P&gt;ns = tot_ns;&lt;/P&gt;
&lt;P&gt;trt='Total';&lt;/P&gt;
&lt;P&gt;trtc='E';&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;drop tot_ns;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's ready for PROC PRINT or whatever you decide the next step should be.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 18:50:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-sum-value-for-only-a-few-rows-of-values/m-p/330943#M74324</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-08T18:50:49Z</dc:date>
    </item>
  </channel>
</rss>

