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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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