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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.