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
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!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.