<?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 how to do sum of the rows and place the results in below blank row by using datasetp in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936951#M368195</link>
    <description>&lt;P&gt;data xyz;&lt;/P&gt;
&lt;P&gt;input var1 var2;&lt;/P&gt;
&lt;P&gt;monday 13&lt;/P&gt;
&lt;P&gt;monday 12&lt;/P&gt;
&lt;P&gt;total .&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tuesday 10&lt;/P&gt;
&lt;P&gt;tuesday 23&lt;/P&gt;
&lt;P&gt;total .&lt;/P&gt;
&lt;P&gt;wednesday 34&lt;/P&gt;
&lt;P&gt;wednesday 43&lt;/P&gt;
&lt;P&gt;total .&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how to get the sum of by using var1 and place the results for total rows in var2 in data step?&lt;/P&gt;
&lt;P&gt;i.e. no proc procedure/proc sql i shall use to get the answer.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Jul 2024 12:52:08 GMT</pubDate>
    <dc:creator>sahoositaram555</dc:creator>
    <dc:date>2024-07-24T12:52:08Z</dc:date>
    <item>
      <title>how to do sum of the rows and place the results in below blank row by using datasetp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936951#M368195</link>
      <description>&lt;P&gt;data xyz;&lt;/P&gt;
&lt;P&gt;input var1 var2;&lt;/P&gt;
&lt;P&gt;monday 13&lt;/P&gt;
&lt;P&gt;monday 12&lt;/P&gt;
&lt;P&gt;total .&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;tuesday 10&lt;/P&gt;
&lt;P&gt;tuesday 23&lt;/P&gt;
&lt;P&gt;total .&lt;/P&gt;
&lt;P&gt;wednesday 34&lt;/P&gt;
&lt;P&gt;wednesday 43&lt;/P&gt;
&lt;P&gt;total .&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how to get the sum of by using var1 and place the results for total rows in var2 in data step?&lt;/P&gt;
&lt;P&gt;i.e. no proc procedure/proc sql i shall use to get the answer.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 12:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936951#M368195</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2024-07-24T12:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to do sum of the rows and place the results in below blank row by using datasetp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936953#M368196</link>
      <description>&lt;P&gt;Typically, this is not a good idea to store these sums in a SAS data set in the same column as the raw data. Better would be to have these results in a report of some type, or put the sums in a different column. Do you have a preference?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 13:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936953#M368196</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-24T13:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to do sum of the rows and place the results in below blank row by using datasetp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936955#M368197</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, at the moment the data structure is like this and it would be great if i get help to find a solution for a sum value for the total row which makes the further downstream work much easier.&lt;BR /&gt;</description>
      <pubDate>Wed, 24 Jul 2024 13:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936955#M368197</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2024-07-24T13:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to do sum of the rows and place the results in below blank row by using datasetp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936957#M368198</link>
      <description>&lt;P&gt;Putting a sum in the same column as the raw data will make downstream work more difficult. Unless you already have downstream code that requires the data be in this layout.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 13:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936957#M368198</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-24T13:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to do sum of the rows and place the results in below blank row by using datasetp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936959#M368199</link>
      <description>It's fine if the sum value is coming in a new column along with the prerequisite values, but the intention is not to disturb the rows. i.e. basically for monday,&lt;BR /&gt;monday 13 13&lt;BR /&gt;monday 12 12&lt;BR /&gt;tuesday .    25&lt;BR /&gt;something like above would work too!</description>
      <pubDate>Wed, 24 Jul 2024 13:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936959#M368199</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2024-07-24T13:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to do sum of the rows and place the results in below blank row by using datasetp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936963#M368200</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
     create table want as select *,sum(var2) as sum_var2
     from have
     group by var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Jul 2024 13:18:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/936963#M368200</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-07-24T13:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to do sum of the rows and place the results in below blank row by using datasetp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/937017#M368209</link>
      <description>&lt;P&gt;PROC SUMMARY (aka MEANS) is best tool for calculating sums.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data xyz;
  input var1 :$9. var2;
cards;
monday 13
monday 12
tuesday 10
tuesday 23
wednesday 34
wednesday 43
;

proc summary data=xyz nway;
  class var1;
  var var2;
  output out=total sum=;
run;

data want;
  set xyz total;
  by var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that I purposely left the _TYPE_ and _FREQ_ variables that PROC SUMMARY added in the dataset so you can tell which observations are the totals.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1721836390660.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/98701i018CE69FE55DB11F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1721836390660.png" alt="Tom_0-1721836390660.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 15:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/937017#M368209</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-07-24T15:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to do sum of the rows and place the results in below blank row by using datasetp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/937069#M368211</link>
      <description>&lt;P&gt;It seems that is an interview question.&lt;/P&gt;
&lt;P&gt;Nonsense for real world.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data xyz;
input var1 :$20. var2;
cards;
monday 13
monday 12
total .  
tuesday 10
tuesday 23
total .
wednesday 34
wednesday 43
total .
;

data want;
 set xyz;
 cum+var2;
 if var1='total' then do;var2=cum;cum=.;end;
 drop cum;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Jul 2024 00:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-do-sum-of-the-rows-and-place-the-results-in-below-blank/m-p/937069#M368211</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-07-25T00:39:47Z</dc:date>
    </item>
  </channel>
</rss>

