Here diff has some estimate and for each observation - let's say if fyear = 2020, I need to calculate the sum of diff past 16 quarters including 2020.
gen sig = .
replace sig = sum(diff) if(co_code_i == co_code_i[_n] & co_code_j == co_code_j[_n] & nic_prod_code == nic_prod_code[_n] & fyear >= fyear[_n]-3 & fyear <= fyear[_n])
I'm not getting the desired output. Can anyone please suggest a way to perform this operation?
Related Posts with Summing observations of a variable with if - conditions
Probit Interaction Marginal EffectsI would like to test if the "gap" in a discrete variable,Y, changes between two groups from year to …
Error in -merge- commandHi, I have to merge about 40 datasets using a key ID. The "hhid" variable present in all datasets, b…
forbidden regression (quadratic regression)Dear All, Suppose that I regress y on x and x^2, along with other covariates. In addition, x is endo…
How to use esttab with psmatch2?Hi everyone, I am using propensity score matching for my research. I wanted to use esttab to create…
Marginsplot cut off y axisDear Statalist I am running a regression and I am plotting my graphs using marginsplot marginsplot…
Subscribe to:
Post Comments (Atom)
0 Response to Summing observations of a variable with if - conditions
Post a Comment