BookmarkSubscribeRSS Feed
PurushReddy
Fluorite | Level 6
Data ds1;
Input empid salary1 Salary2;
Cards;
101 45000 65000
102 56000 54333
103 43000 67777
104 43000 65000
105 45000 56000
106 56000 56788
Run;
I want output like this
empid salary1. Salary2
101 45000. 65000
102 56000 54333
103 43000 67777
104 43000 65000
105. 45000 56000
106. 56000 56788
Total=. Total=

I want sum value in total='this place'
3 REPLIES 3
Kurt_Bremser
Super User

In proc report, create a summary line:

 

Data ds1;
Input empid $ salary1 Salary2;
Cards;
101 45000 65000
102 56000 54333
103 43000 67777
104 43000 65000
105 45000 56000
106 56000 56788
;

proc report data=ds1;
column empid salary1 salary2;
define empid /display;
define salary1/analysis;
define salary2/analysis;
rbreak after / summarize;
compute after;
  empid = 'Total';
endcomp;
run;

Result:

 

empid	salary1	Salary2
101	45000	65000
102	56000	54333
103	43000	67777
104	43000	65000
105	45000	56000
106	56000	56788
Total	288000	364898
Jagadishkatam
Amethyst | Level 16

try the below code

 

Data ds1;
Input empid salary1 Salary2;
Cards;
101 45000 65000
102 56000 54333
103 43000 67777
104 43000 65000
105 45000 56000
106 56000 56788
;
Run;

proc sql;
create table want as select * from ds1 
union all
select . as id , sum(salary1) as salary1, sum(salary2) as salary2 from ds1;
quit;
Thanks,
Jag
FreelanceReinh
Jade | Level 19

For a quick output PROC PRINT is sufficient:

proc print data=ds1;
sum s:;
run;

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
  • 3 replies
  • 427 views
  • 1 like
  • 4 in conversation