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