BookmarkSubscribeRSS Feed
Swati24
Obsidian | Level 7
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

GroupCount
Group Total13
4 REPLIES 4
singhsahab
Lapis Lazuli | Level 10

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 🙂 

Jagadishkatam
Amethyst | Level 16

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;
Thanks,
Jag
Kurt_Bremser
Super User

@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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1178 views
  • 2 likes
  • 4 in conversation