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
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.