I have customer transaction data where some invoice numbers are missing. I would like to fill the missing invoice numbers with the preceding row value if both the customer id's are equal in the rows and the transaction amounts are equal. Date is not important.
An example of what the data looks like is:
date customer amount invoice
01/13 A 10 1
02/13 B 20 2
03/13 B 20 NA
04/13 C 30 3
05/13 C 60 NA
06/13 D 50 4
and what I am trying to create is:
date customer amount invoice
01/13 A 10 1
02/13 B 20 2
03/13 B 20 2
04/13 C 30 3
05/13 C 60 NA - this NA remains because amount does not match
06/13 D 50 4