<?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 sum calculate a sum across rows? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856453#M37787</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437400"&gt;@AVUH777&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Basically, I would need to add up hours worked between rows. For example, I would need to add 60+55+20 for the first row, while for the second row, I would need to add 89 + 22.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You and I obviously understand the words "across" and "between" differently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nevertheless, why in the second row is it 89+22 and NOT 89+22+74+78?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The sum function will add values in a row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sum_of_row=sum(Director,Engineers,TeamLeads,AdditionalStaff);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2023 13:06:18 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-01-31T13:06:18Z</dc:date>
    <item>
      <title>How to sum calculate a sum across rows?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856336#M37781</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm attempting to calculate sums across rows. I would need to sometimes calculate the sum of all rows, while other times calculate the sum of only two or three rows. How can I do this? An example of my data is below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.HOURS;&lt;BR /&gt;input Director Engineers TeamLeads AdditionalStaff;&lt;BR /&gt;datalines;&lt;BR /&gt;60 55 20 52&lt;BR /&gt;89 22 74 78&lt;BR /&gt;78 11 69 47&lt;BR /&gt;77 24 59 25&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 20:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856336#M37781</guid>
      <dc:creator>AVUH777</dc:creator>
      <dc:date>2023-01-30T20:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum calculate a sum across rows?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856343#M37782</link>
      <description>&lt;P&gt;Could you give an example of how you would like the output to look?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 21:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856343#M37782</guid>
      <dc:creator>russt_sas</dc:creator>
      <dc:date>2023-01-30T21:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum calculate a sum across rows?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856351#M37783</link>
      <description>&lt;P&gt;If you have variables that contain what would describe the "groups of rows" to sum then proc summary will do this. Best practice is likely to have one or more variables that indicate which groups you want to add.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example. Note that I added a couple of variables to identify groups. When you examine the output data set you will see combinations of the variables that appear on the CLASS statements along with a variable _type_ that identifies a specific combination. The first record, _type_=0 will have a summary of ALL&amp;nbsp; the records. Then depending on the order of variables on the class statements the groups of each of the other variables taken one at a time, then two at a time .....&lt;/P&gt;
&lt;PRE&gt;data WORK.HOURS;
input region $ branch $ Director Engineers TeamLeads AdditionalStaff;
datalines;
AAA bbb 60 55 20 52
AAA bbb 89 22 74 78
AAA ccc 89 22 74 78
CCC ddd 11 69 47
CCC eee 77 24 59 25
CCC eee 7 4 5 2
;
run;

proc summary data=work.hours;
   class region branch;
   var  Director Engineers TeamLeads AdditionalStaff;
   output out=summary  Sum= ;
run;&lt;/PRE&gt;
&lt;P&gt;You can select specific values of _type_ for conditional processing. There is also a variable _freq_ that has the number of observations for each row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have used this with up to 9 variables to summarize all the variables I needed an then selected which bits go into which part of a report by using the _type_ variable and a Where statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 22:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856351#M37783</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-30T22:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum calculate a sum across rows?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856353#M37784</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437400"&gt;@AVUH777&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would need to sometimes calculate the sum of all rows, &lt;FONT color="#FF0000"&gt;while other times calculate the sum of only two or three rows&lt;/FONT&gt;. How can I do this? An example of my data is below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The above in red needs a lot more explanation. Also, I assume you mean sum of a variable (down a column, not across rows), is that right?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 22:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856353#M37784</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-30T22:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum calculate a sum across rows?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856449#M37785</link>
      <description>&lt;P&gt;Basically, I would need to add up hours worked between rows. For example, for the first row, I would need to add 60+55+20, while for the second row, I would need to add 89 + 22.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 12:49:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856449#M37785</guid>
      <dc:creator>AVUH777</dc:creator>
      <dc:date>2023-01-31T12:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum calculate a sum across rows?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856450#M37786</link>
      <description>Basically, I would need to add up hours worked between rows. For example, I would need to add 60+55+20 for the first row, while for the second row, I would need to add 89 + 22.</description>
      <pubDate>Tue, 31 Jan 2023 12:48:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856450#M37786</guid>
      <dc:creator>AVUH777</dc:creator>
      <dc:date>2023-01-31T12:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum calculate a sum across rows?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856453#M37787</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437400"&gt;@AVUH777&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Basically, I would need to add up hours worked between rows. For example, I would need to add 60+55+20 for the first row, while for the second row, I would need to add 89 + 22.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You and I obviously understand the words "across" and "between" differently.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nevertheless, why in the second row is it 89+22 and NOT 89+22+74+78?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The sum function will add values in a row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sum_of_row=sum(Director,Engineers,TeamLeads,AdditionalStaff);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 13:06:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856453#M37787</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-31T13:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum calculate a sum across rows?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856455#M37788</link>
      <description>I guess so! I did really struggle with determining the best way to phrase this question lol but nevertheless, thanks for your help!</description>
      <pubDate>Tue, 31 Jan 2023 13:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-sum-calculate-a-sum-across-rows/m-p/856455#M37788</guid>
      <dc:creator>AVUH777</dc:creator>
      <dc:date>2023-01-31T13:11:53Z</dc:date>
    </item>
  </channel>
</rss>

