Hi,
Would anyone know how to, by using PROC SQL merge duplicate variables rows and this would result in a sum up of one column?
tried SELECT DISTINCT and GROUP BY but I am still receiving multiple duplicates.
4 duplicate rows showing for each Product #... if I do PROC SORT nodupkey then it will remove all but 1 and the amount for Jan will not be correct...
please HELP
this is what I am getting
Product# | JAN_CODE | JAN_AMOUNT | FEB_CODE | FEB_AMOUNT |
73560136 | VCRD10_12 | 6.38 | VCRD10_12 | 10 |
73560136 | VCRD10_12 | 3.62 | VCRD10_12 | 10 |
73560136 | VCRD10_12 | 6.38 | VCRD10_12 | 10 |
73560136 | VCRD10_12 | 3.62 | VCRD10_12 | 10 |
75458710 | VCRD10_12 | 3.02 | VCRD10_12 | 10 |
75458710 | VCRD10_12 | 6.98 | VCRD10_12 | 10 |
75458710 | VCRD10_12 | 3.02 | VCRD10_12 | 10 |
75458710 | VCRD10_12 | 6.98 | VCRD10_12 | 10 |
76307732 | VCRD10_12 | 7.89 | VCRD10_12 | 10 |
76307732 | VCRD10_12 | 2.11 | VCRD10_12 | 10 |
76307732 | VCRD10_12 | 7.89 | VCRD10_12 | 10 |
76307732 | VCRD10_12 | 2.11 | VCRD10_12 | 10 |
79854058 | VCRD10_12 | 3.02 | VCRD10_12 | 10 |
79854058 | VCRD10_12 | 6.98 | VCRD10_12 | 10 |
79854058 | VCRD10_12 | 3.02 | VCRD10_12 | 10 |
79854058 | VCRD10_12 | 6.98 | VCRD10_12 | 10 |
but what I want is
Product# | JAN_CODE | JAN_AMOUNT | FEB_CODE | FEB_AMOUNT |
73560136 | VCRD10_12 | 10 | VCRD10_12 | 10 |
75458710 | VCRD10_12 | 10 | VCRD10_12 | 10 |
76307732 | VCRD10_12 | 10 | VCRD10_12 | 10 |
79854058 | VCRD10_12 | 10 | VCRD10_12 | 10 |
I would look at steps prior and ensure that the duplicates aren't made. Likely doing the sum before the "merge" might help.
Please make us a small example with input data and code.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.