I have this table that have the volume for each product:
PRODUCT | VOLUME |
NK | 200 |
CN | 180 |
CY | 220 |
And another table the have the percentage share for each country:
REGION | SHARE |
AUSTRALIA | 0.45 |
CHINA | 0.55 |
I want this output, the propotion the volume of each product by each country
PRODUCT | REGION | VOLUME |
NK | AUSTRALIA | 90 |
NK | CHINA | 110 |
CN | AUSTRALIA | 81 |
CN | CHINA | 99 |
CY | AUSTRALIA | 99 |
CY | CHINA | 121 |
How do I achieve this in PROC SQL? I have simplified the table, in real there are more columns.
You're looking for a cross join or natural join.
You can use a.*, b.* to specify keeping all columns in each table.
proc sql;
create table want as
select a.*, b.*, a.volume*b.share as volume_proportion
from table1 as a
CROSS JOIN table2 as b
order by a.product, b.region;
quit;
You're looking for a cross join or natural join.
You can use a.*, b.* to specify keeping all columns in each table.
proc sql;
create table want as
select a.*, b.*, a.volume*b.share as volume_proportion
from table1 as a
CROSS JOIN table2 as b
order by a.product, b.region;
quit;
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: