BookmarkSubscribeRSS Feed
sufiya
Quartz | Level 8

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_CODEJAN_AMOUNTFEB_CODEFEB_AMOUNT
73560136VCRD10_126.38VCRD10_1210
73560136VCRD10_123.62VCRD10_1210
73560136VCRD10_126.38VCRD10_1210
73560136VCRD10_123.62VCRD10_1210
75458710VCRD10_123.02VCRD10_1210
75458710VCRD10_126.98VCRD10_1210
75458710VCRD10_123.02VCRD10_1210
75458710VCRD10_126.98VCRD10_1210
76307732VCRD10_127.89VCRD10_1210
76307732VCRD10_122.11VCRD10_1210
76307732VCRD10_127.89VCRD10_1210
76307732VCRD10_122.11VCRD10_1210
79854058VCRD10_123.02VCRD10_1210
79854058VCRD10_126.98VCRD10_1210
79854058VCRD10_123.02VCRD10_1210
79854058VCRD10_126.98VCRD10_1210

 

 

but what I want is 

 

Product#JAN_CODEJAN_AMOUNTFEB_CODEFEB_AMOUNT
73560136VCRD10_1210VCRD10_1210
75458710VCRD10_1210VCRD10_1210
76307732VCRD10_1210VCRD10_1210
79854058VCRD10_1210VCRD10_1210
2 REPLIES 2
ballardw
Super User

I would look at steps prior and ensure that the duplicates aren't made. Likely doing the sum before the "merge" might help.

 

PGStats
Opal | Level 21

Please make us a small example with input data and code.

PG

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1142 views
  • 0 likes
  • 3 in conversation