Hey guys,
I am rather new to Stata and it seems like I am currently discovering my boundaries. I'd be very happy if someone is able to help me!
So i do have Panel Data - my time variable is MONTH (for example: 2000m7). ID is my identifier.
There is a variable called PRICE. I want to replace observations that have a missing value (that's what a " . " is called - right?) with the last available observation.
In principle I'd use:
However, there is a slight problem: I only want to use the last observation if it is not older than 6 months (if the last observation is older than 6 months I'd like to keep a missing value). Moreover, there might be gaps - so I guess using _n is not a good idea for an optimal solution.
Thank you in advance!
Best regards
Mike
I am rather new to Stata and it seems like I am currently discovering my boundaries. I'd be very happy if someone is able to help me!
So i do have Panel Data - my time variable is MONTH (for example: 2000m7). ID is my identifier.
There is a variable called PRICE. I want to replace observations that have a missing value (that's what a " . " is called - right?) with the last available observation.
In principle I'd use:
Code:
bys ID (MONTH): replace PRICE = PRICE[_n-1] if PRC == .
Thank you in advance!
Best regards
Mike
Comment