Hi. My dataset has an id variable, a total amount variable and the corresponding date variable. There are multiple observations per id and within a single id there are sometimes negative numbers of the same positive number in another observation. For every negative value I want to flag just one positive value. I don't have a clear identifier for a corresponding positive value.
For example, in the given table below, I want to flag the first two entries for id 1. For id 3, I want to flag the second and third (or fourth - but just one of these) entries. For id 4, I want to flag the first, second, third and fourth entry.
Id Total_Amount Date
1 34 03jul2018
1 -34 03jul2018
1 25 05may2015
2 13 12nov2016
2 14 11jun2019
3 43 01jan2014
3 -456 22mar2017
3 456 22mar2017
3 456 22mar2017
4 756 28apr2015
4 756 28apr2015
4 -756 28apr2015
4 -756 28apr2015
4 143 03oct2017