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
convert northing and easting to longtitude and latitudeHi, is there a code for converting "northing" and "easting" to longitude and latitude? Many thanks! …
Two Step Binary Choice Regression Model: What type of regression model to use to avoid sample selection bias and autocorrelation?Hi, I have a two step-model (see below) in which all the people answer the question in the first par…
Looking for methological adviceHi everyone, I'm looking for methodological advice on the undertaking described below. I tried to s…
Regression Discontinuity - RDDensity test (Cattaneo)Hello everyone, This is my first time using Statalist as well as first time trying to do anything w…
Drop observation if missing in two discontinous yearsHello, I have a lot of balance sheet data (with a lot of variables). What I need is for every idnr …
Subscribe to:
Post Comments (Atom)
0 Response to Summing observations of a variable with if - conditions
Post a Comment