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
Generate spatial weight matrix by using "spweight"Hi everybody, I am working on Emad A. Shehata's spatial command modules, but I got a trouble in cre…
Grs testHi Statalist Members! I am conducting a research on variation of the average returns on 12 portfoli…
Tabs for multiple subgroups in one tableI am hoping to run tabs for by various subgroups (different job roles, in this instance). For my tw…
M Jones ModelHi,Is the following code true for the m jones model? data: 2010-2017 for 35 country and 24 industry …
Do you need to use the same number of data observations for different types of regression?Hello, I want to perform a linear (1 independent variable) and a multiple regression with a sample …
Subscribe to:
Post Comments (Atom)
0 Response to Summing observations of a variable with if - conditions
Post a Comment