I have a dataset with the US census for the 1970-1999 period combined with a dataset with information about different public policies concerning the labor market. I have a cross-section of several million individuals, with a variable indicating the state of birth. I also have a series of dummy variables indicating if a policy was active at each of the available years. For example, if in Nevada the policy called G started in 1980 and was active for the rest of the period, for individuals born in Nevada, the dummy variables g_1970birth-g_1979birth will be 0, while the variables g_1980birth-g_1999birth will be 1.
I want to create a new variable, call it year_g, which will give me the year the policy G started in for the state of birth of each individual (year_g=1980 for the previous example). For that purpose, I have written the following line:
Code:
forval w=1970(1)1999{ replace year_g=`w' if g_`w'birth==1 & g_`w-1'birth==0 }
Thank you very much for your time.
0 Response to Function to give year of start
Post a Comment