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.
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.
Ready to level-up your skills? Choose your own adventure.