Sum up

Reply
Contributor
Posts: 43

Sum up

Please Check the attached file. I need to sum up the columns as shown in the attached file

Please Guide me with various possible ways.

Thank you

Attachment
Super User
Posts: 5,260

Re: Sum up

PROC REPORT.

Data never sleeps
Frequent Contributor
Posts: 83

Re: Sum up

The easiest way likely would be to use proc sql, though that is just what I prefer to go down columns. As long as you just want the aggregates of each of these groups the below code will work. Granted if you wanted to tack it on to the bottom of the file that the data came in from then you could not rename any of the variables and use union corr to the original dataset.

proc sql;

create table want as

select distinct items, count(unique(dept)) as c_dept, (sum(orders)) as s_orders, (sum(quantity)) as s_quan,

(sum(net_amount)) as s_net

from have

group by items;

quit;

Super User
Super User
Posts: 6,502

Re: Sum up

Since you output looks like a report, just use one of SAS's many reporting options.

You could even just use PROC PRINT.

proc print data=have ;

  by Items;

  id Items ;

  var  Dept Orders Quantity Net_amount ;

  sum Orders Quantity Net_amount;

run;

Ask a Question
Discussion stats
  • 3 replies
  • 204 views
  • 6 likes
  • 4 in conversation