Hi, EM newbie. I have a data set that has multiple observations. I want to consolidate the ID's and sum the corresponding Wire.
I have been attempting to do it by attaching a SAS Code node to my file import node and running a PROC Sort command. I will then want to merge this data with another file.
Is the PROC Sort command the right way to go, if so please help with syntax... or is there an easier way.
Thanks!
Seth
Original Data | Desired Output | ||
ID | Wire | ID | Wire |
18 | 1 | 18 | 1 |
77 | 2 | 77 | 8 |
77 | 6 | 110 | 14 |
110 | 5 | 116 | 1 |
110 | 9 | 378 | 0 |
116 | 1 | 667 | 1 |
378 | 0 | ||
667 | 1 | ||
667 |
or you could use proc summary:
proc summary data=in_data nway;
var wire;
class id;
output out=want(keep=id total) sum=total;
run;
proc print data=want;run;
How about this?
data in_data;
input ID Wire ;
cards;
18 1
77 2
77 6
110 5
110 9
116 1
378 0
667 1
;
proc sql;
create table want as
select id, sum(wire) as sum_wire
from in_data
group by id;
quit;
Anca.
or you could use proc summary:
proc summary data=in_data nway;
var wire;
class id;
output out=want(keep=id total) sum=total;
run;
proc print data=want;run;
Thanks!
Seth
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.
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.