BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SAS49
Obsidian | Level 7
ID1ID2Length
A_001A_005450
A_001A_005600
A_001A_005700
A_001A_006350
A_001A_006800
A_005A_006900
A_005A_006750

 

Hi all, I am very new to SAS.  I have a data table of comparisons between 2 different IDs (found in columns 1 and 2), and the lengths shared between them.   There are multiple lengths listed for these different pairs.  I want the sum of lengths for each of the matching pairs and to output that as a separate data table.  See the example below: 

 

ID1ID2Length
A_001A_0051750
A_001A_0061150
A_005A_0061650

 

How would I accomplish this in SAS?  I honestly have no idea where even to start.  I appreciate any advice!  I am working in SAS 9.4. 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

I would let PROC SUMMARY have all the fun.

 

proc summary data=have nway;
    class id1 id2;
    var length;
    output out=want sum=;
run;
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

I would let PROC SUMMARY have all the fun.

 

proc summary data=have nway;
    class id1 id2;
    var length;
    output out=want sum=;
run;
--
Paige Miller
tarheel13
Rhodochrosite | Level 12
proc sql;
create table want as
select id1, id2, sum(length) as length
from have 
group by id1, id2;
quit;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 2 replies
  • 2365 views
  • 0 likes
  • 3 in conversation