If I group the data I have by name and id, I want to add a new row per group if the first code = last code, the new row need to have the same name and id, and the value of the 'amount' column is N/A, the values for the rest columns can just be the same as one of the rows in the group (can also just be empty, doesn't really matter). data have; input name : $1. id : 8. code : $8. amount : 8. ; datalines; A 10 12345678 100 A 10 09876543 30 B 9 88997700 20 B 9 88997700 -20 B 9 88997700 40 C 28 11223344 30 C 28 11223344 40 C 28 67676767 50 D 10 78654890 40 D 10 78654890 50 ; data want; input name : $1. id : 8. code : $8. amount : 8. ; datalines; A 10 12345678 100 A 10 09876543 30 B 9 88997700 20 B 9 88997700 -20 B 9 88997700 40 B 9 88997700 N/A C 28 11223344 30 C 28 11223344 40 C 28 67676767 50 D 10 78654890 40 D 10 78654890 50 D 10 78654890 N/A ;
... View more