I am having some trouble creating a variable with an additive string of lagged variables.
To derive a causal effect of education spending on graduation rates it is necessary to regress on spending from all 12 years of a students education, rather than just one year. To do this I want to create new variable "gradsaid," which sums expenditures from the previous twelve years. I have 22 years of data on approximately 700 school districts for 13,825 observations.
I have used the following command:
tsset District year, yearly
generate gradsaid = (STATE_AID + L.STATE_AID + L1.STATE_AID + L2.STATE_AID + L3.STATE_AID + L4.STATE_AID + L5.STATE_AID + L6.STATE_AID+ L7.STATE_AID + L8.STATE_AID + L9.STATE_AID + L10.STATE_AID + L11.STATE_AID)
but when I run this command it generates 13,318 missing values. it generates the desired value only for year 2014 (the most recent year in my panel) with all 21 prior years missing.
heres an interesting twist, when I try to sum over five lagged years with the following command something different happens:
tsset District year, yearly
generate gradsaid = (STATE_AID + L.STATE_AID + L1.STATE_AID + L2.STATE_AID + L3.STATE_AID + L4.STATE_AID)
Now there are only 5,976 missing values generated. I now have observations of the desired value for the years 2007-2014 and 1997-2001 with the rest of the years missing.
ive tried destringing my District, Year and STATE_AID variables with no success.
Does anyone have a guess of what's going on?
To derive a causal effect of education spending on graduation rates it is necessary to regress on spending from all 12 years of a students education, rather than just one year. To do this I want to create new variable "gradsaid," which sums expenditures from the previous twelve years. I have 22 years of data on approximately 700 school districts for 13,825 observations.
I have used the following command:
tsset District year, yearly
generate gradsaid = (STATE_AID + L.STATE_AID + L1.STATE_AID + L2.STATE_AID + L3.STATE_AID + L4.STATE_AID + L5.STATE_AID + L6.STATE_AID+ L7.STATE_AID + L8.STATE_AID + L9.STATE_AID + L10.STATE_AID + L11.STATE_AID)
but when I run this command it generates 13,318 missing values. it generates the desired value only for year 2014 (the most recent year in my panel) with all 21 prior years missing.
heres an interesting twist, when I try to sum over five lagged years with the following command something different happens:
tsset District year, yearly
generate gradsaid = (STATE_AID + L.STATE_AID + L1.STATE_AID + L2.STATE_AID + L3.STATE_AID + L4.STATE_AID)
Now there are only 5,976 missing values generated. I now have observations of the desired value for the years 2007-2014 and 1997-2001 with the rest of the years missing.
ive tried destringing my District, Year and STATE_AID variables with no success.
Does anyone have a guess of what's going on?
Comment