This is my original problem: How would I be able to remove opposite values (e.g. refunds) in panel data?
Given the following data:
id|datee | price | quant | discrete_x
1 2018-12-19 4 -3000 A
1 2018-12-04 4 3000 A
1 2018-12-21 4 3000 B
1 2018-12-20 3 2000 A
...
this is my desired output:
id|datee | price | quant | discrete_x
1 2018-12-21 4 3000 B
1 2018-12-20 3 2000 A
...
The two removed rows are identical except for date and quant. Is there a way to match two different rows for certain variables?
Another requirement would be to make sure that the negative quant comes after the matching row date-wise.