Hi Sas Experts,
Am summing marks1 and marks2 by using multiple byvals, and am getting the totals as two times.
I don't want to see the repeating totals, Please help.
Here is my code:
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;
options nobyline;
ods pdf file="path.pdf" startpage=no;
ods pdf startpage= bygroup;
title1 j=l "SAME -- #byval2";
proc print data=new noobs
sumlabel='Total' grandtotal_label='grand Total';
by name name1;
sum marks1 marks2;
title2 '^{newline 2}EACH-- @ #byval1';
run;
title1;
ods pdf close;
Kind regrads,
Sanjay
As with anything like this, I always do manipulations outside the reporting procedure. This keeps your dataset having everything needed (good for validation) and the reporting procedure simple (good for coding). Plus you can manipulate things anyway you like then.
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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.