I have a panel survey data of each individual's price forecast. In each month, a subset of first-time respondents and a subset of re-contact respondents from 6 months ago are selected. For example, the data table looks like:
yyyymm id previousid previousyyyymm forecast
2007m1 1 5
2007m1 2 6
... ... ...
2007m7 1 7
2007m7 2 8
2007m7 3 1 2007m1 10
2007m7 4 2 2007m1 12











I want to generate a new variable called forecast revision(FR) so that for id=3 and id=4 in 2007m7, the values of their FR will be 10-5=5 and 12-6=6. I think I should iterate over observations and for each observation, if previousid is not missing, match it with the same value of id from the observations 6 months ago. But I have two questions. First I am not sure how to substract 6 months from the current date. Second I am not sure if I should use a merge command. Could someone give me a hint? Thank you!

Sincerely,
Victoria