BookmarkSubscribeRSS Feed
Dipu
Calcite | Level 5

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

3 REPLIES 3
LinusH
Tourmaline | Level 20

PROC REPORT.

Data never sleeps
overmar
Obsidian | Level 7

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;

Tom
Super User Tom
Super User

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 520 views
  • 6 likes
  • 4 in conversation