Hi guys,
First of all my apologies if this question is simple, but it was hard to search for similar questions.
I have a dataset like this:
a | b | count | dif |
6 | | 6 | 6 |
19 | | 19 | 13 |
| 32 | 32 | 13 |
91 | | 91 | 59 |
105 | | 105 | 14 |
| 143 | 143 | 38 |
| | 144 | 1 |
172 | | 172 | 28 |
| 199 | 199 | 27 |
| 272 | 272 | 42 |
326 | | 326 | 54 |
356 | | 356 | 30 |
Column count equals either a or b, whichever is not missing; while dif is simply the difference between each observation in count and its lag value. My desired output is this:
a | b | count | dif |
6 | | 6 | 6 |
19 | | 19 | 13 |
91 | | 91 | 59 |
105 | | 105 | 14 |
172 | | 172 | 28 |
326 | | 326 | 54 |
356 | | 356 | 30 |
This is to say, I want to keep only observations where a is not missing, while keeping dif value as it was. But once I use where a ne .; the new dif adjusts itself automatically (e.g. row 3 becomes 72 rather than 59). Any suggestions would be greatly appreciated.
Cheers
Roy