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

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!

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.

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
  • 1 reply
  • 598 views
  • 0 likes
  • 2 in conversation