BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi, I'm currently working with two data sets similar to:

#1:
data parts;

part_no price
123 15
234 25
237 20
355 28
789 55

#2:
data sales;

ID Trans_NO Part_NO Quantity
03 1 234 5
03 1 123 9
03 2 237 4
01 1 355 5
01 1 234 3
01 1 123 9
01 2 355 5
02 1 237 11

I want to make a new data set that only shows ID (sorted by ID), the transaction
number, and the total sale for each transaction.

I think I need to first merge the two data sets by Part_no so that I can
compute to total sale, but I'm having trouble with what to do after this to get the proper dataset.
Any help would be much appreciated!
Helena
1 REPLY 1
LinusH
Tourmaline | Level 20
I think that a SQL join would more appropriate/easier to do.
You can calculate sales per row, and then summarize per transaction no in one step: (pseudo-code):

create table total_sales as
select id, trans_no, quantity * price as total_sale
from sales left join parts
on sales.part_no eq parts.part_no
group by id, trans_no
;

/Linus
Data never sleeps

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 825 views
  • 0 likes
  • 2 in conversation