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
STATA has started crashing when using the "Browse" button to import CSV filesEssentially as the title describes, STATA has just started crashing when I use the "Browse" button t…
Searching 1) for user written commands and 2) searching my .do filesHello I have 2 questions about searching in Stata 1) which is the best way to search the user/commun…
Merging and grouping observations by industryHello, I have two datasets which are related, in the first one i have "all types of capital net (so…
Logistic postestimation for survey dataHello, I want to do a logistic regression with survey data so I am using the svy prefix. How do I ge…
Estimating the gravity model using PPLM, general adviceHi, For my thesis I am intending to estimate a gravity model, looking at specifically the effect of…
Subscribe to:
Post Comments (Atom)
0 Response to Summing observations of a variable with if - conditions
Post a Comment