How group merge duplicate rows using PROC SQL

Reply
Contributor
Posts: 34

How group merge duplicate rows using PROC SQL

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
Super User
Posts: 13,542

Re: How group merge duplicate rows using PROC SQL

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

 

Esteemed Advisor
Posts: 5,528

Re: How group merge duplicate rows using PROC SQL

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

PG
Ask a Question
Discussion stats
  • 2 replies
  • 97 views
  • 0 likes
  • 3 in conversation