data one;
infile datalines;
input Group :$10. Count;
datalines;
R&D 2
Testing 3
Sales 8
;
run;
I have a data set like above and I need the output like this
Group | Count |
Group Total | 13 |
proc sql;
create table want as
select
'Group Total' as group,
sum(count) as count
from one;
quit;
Hello,
data one;
infile datalines;
input Group :$10. Count;
datalines;
R&D 2
Testing 3
Sales 8
;
run;
proc sql ;
select 'Group Total' as Group,sum(count) as count from one;
quit;
or
proc sql ;
create table want as
select 'Group Total' as Group,sum(count) as count from one;
quit;
Thanks 🙂
alternatively in a data step with end option and sum function
data want(drop=count rename=(count2=count));
set one end=eof;
count2+count;
if eof;
run;
@Jagadishkatam wrote:
alternatively in a data step with end option and sum function
data want; set one end=eof; count_+count; if eof; run;
Neat. Needs just a little code to create the wanted summary line text.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.