Dear all,
I have a large dataset and want to count observations with particular characteristics. Precisely, I count the number of people in a municipality at that year from a certain nationality. My intuitive solution is to loop over these three dimensions and it works.
However, it is computationally expensive and Stata takes very long to perform the calculations. Therefore, I wanted to ask whether perhaps somebody has an idea to make the calculation more efficient?
Best,
Felix
I have a large dataset and want to count observations with particular characteristics. Precisely, I count the number of people in a municipality at that year from a certain nationality. My intuitive solution is to loop over these three dimensions and it works.
Code:
forvalues y = 2010(1)2015 { foreach k of local gemeinden { foreach c of local countries { count if origin == `c' & Gemeinde == "`k'" & Jahr == `y' replace network1Stock_gem = `r(N)' if origin == `c' & Gemeinde == "`k'" & Jahr == `y' } } }
Best,
Felix
Comment