🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 04-07-2022 01:52 PM
(2738 views)
ID1 | ID2 | Length |
A_001 | A_005 | 450 |
A_001 | A_005 | 600 |
A_001 | A_005 | 700 |
A_001 | A_006 | 350 |
A_001 | A_006 | 800 |
A_005 | A_006 | 900 |
A_005 | A_006 | 750 |
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:
ID1 | ID2 | Length |
A_001 | A_005 | 1750 |
A_001 | A_006 | 1150 |
A_005 | A_006 | 1650 |
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Paige Miller
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sql;
create table want as
select id1, id2, sum(length) as length
from have
group by id1, id2;
quit;