<?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: Procprint with multiple #byvals and sum statemants in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Procprint-with-multiple-byvals-and-sum-statemants/m-p/336521#M63002</link>
    <description>&lt;P&gt;As with anything like this, I always do manipulations outside the reporting procedure. &amp;nbsp;This keeps your dataset having everything needed (good for validation) and the reporting procedure simple (good for coding). &amp;nbsp;Plus you can manipulate things anyway you like then.&lt;/P&gt;
&lt;PRE&gt;data new;
  input name $ name1 $ marks1 marks2;
datalines;
abc1 abc 20 30
abc1 abc 40 10
abc2 abc 40 10
abc2 abc 40 10
bca1 bca 30 45
bca1 bca 26 28
bca2 bca 30 45
bca2 bca 26 28
;
run;

data new (drop=name_sum);
  set new;
  by name;
  retain name_sum;
  if first.name then name_sum=0;
  name_sum=sum(name_sum,marks1);
  if not(last.name) then output;
  else do;
    output;
    name="Sum";
    marks1=name_sum;
    output;
  end;
run;

proc print data=new;
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Feb 2017 11:58:53 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-02-28T11:58:53Z</dc:date>
    <item>
      <title>Procprint with multiple #byvals and sum statemants</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Procprint-with-multiple-byvals-and-sum-statemants/m-p/336512#M63000</link>
      <description>&lt;P&gt;Hi Sas Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am summing marks1 and marks2 by using multiple byvals, and am getting the totals as two times.&lt;/P&gt;&lt;P&gt;I don't want to see the repeating totals, Please help.&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data new;&lt;BR /&gt;input name$ name1$ marks1 marks2;&lt;BR /&gt;datalines;&lt;BR /&gt;abc1 abc 20 30&lt;BR /&gt;abc1 abc 40 10&lt;BR /&gt;abc2 abc 40 10&lt;BR /&gt;abc2 abc 40 10&lt;BR /&gt;bca1 bca 30 45&lt;BR /&gt;bca1 bca 26 28&lt;BR /&gt;bca2 bca 30 45&lt;BR /&gt;bca2 bca 26 28&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;options nobyline;&lt;BR /&gt;ods pdf file="path.pdf" startpage=no;&lt;BR /&gt;ods pdf startpage= bygroup;&lt;BR /&gt;title1 j=l "SAME -- #byval2";&lt;BR /&gt;proc print data=new noobs&lt;BR /&gt;sumlabel='Total' grandtotal_label='grand Total';&lt;BR /&gt;by name name1;&lt;BR /&gt;sum marks1 marks2;&lt;BR /&gt;title2 '^{newline 2}EACH-- @ #byval1';&lt;BR /&gt;run;&lt;BR /&gt;title1;&lt;/P&gt;&lt;P&gt;ods pdf close;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regrads,&lt;/P&gt;&lt;P&gt;Sanjay&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2017 11:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Procprint-with-multiple-byvals-and-sum-statemants/m-p/336512#M63000</guid>
      <dc:creator>sanjay1</dc:creator>
      <dc:date>2017-02-28T11:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Procprint with multiple #byvals and sum statemants</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Procprint-with-multiple-byvals-and-sum-statemants/m-p/336521#M63002</link>
      <description>&lt;P&gt;As with anything like this, I always do manipulations outside the reporting procedure. &amp;nbsp;This keeps your dataset having everything needed (good for validation) and the reporting procedure simple (good for coding). &amp;nbsp;Plus you can manipulate things anyway you like then.&lt;/P&gt;
&lt;PRE&gt;data new;
  input name $ name1 $ marks1 marks2;
datalines;
abc1 abc 20 30
abc1 abc 40 10
abc2 abc 40 10
abc2 abc 40 10
bca1 bca 30 45
bca1 bca 26 28
bca2 bca 30 45
bca2 bca 26 28
;
run;

data new (drop=name_sum);
  set new;
  by name;
  retain name_sum;
  if first.name then name_sum=0;
  name_sum=sum(name_sum,marks1);
  if not(last.name) then output;
  else do;
    output;
    name="Sum";
    marks1=name_sum;
    output;
  end;
run;

proc print data=new;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2017 11:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Procprint-with-multiple-byvals-and-sum-statemants/m-p/336521#M63002</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-28T11:58:53Z</dc:date>
    </item>
  </channel>
</rss>

