BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
eyespike1
Calcite | Level 5

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 DataDesired Output
IDWireID Wire
181181
772778
77611014
11051161
11093780
11616671
3780
6671
667
1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

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;

View solution in original post

3 REPLIES 3
AncaTilea
Pyrite | Level 9

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.

Linlin
Lapis Lazuli | Level 10

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;

eyespike1
Calcite | Level 5
Linlin and Anca tilea thank you both for the quick response! I was able to get both to work.

Thanks!

Seth

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to choose a machine learning algorithm

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.

Discussion stats
  • 3 replies
  • 1013 views
  • 3 likes
  • 3 in conversation