Dear forum members,
my data is a panel structured as follows: id change nid1 nid2 nid3 nid4 nid5
For each id, i would like to create a variable that determines how many changes happened in the nids in the previous year. I tried:
egen nn_changes = count(change[_n-1]) if change[_n-1]==1, by( nid1 nid2 nid3 nid4 nid5) but it doesnt seem to work. Is a loop required here?
Your help is appreciated.
Kind regards
Related Posts with Counting observations of nearest neighbours
Calculating ratio with confidence intervalDear All, Do you perhaps have any advice on how to calculate the ratio with 95% confidence interval…
Difference in Sargan after xtdpdsysIs it possilbe to compute difference in Sargan after xtdpdsys ? …
Regression Discontinuity Design for change in speed limitsHey! I`m trying to get graphs for my panel data. I`m looking to graph with a regression discontinui…
Display or Show joint test after estimating REGHDFEHello guys, I run the REGHDFE command to estimating this: reghdfe ly $quatre $cinq, a (cmap dveduc3…
<istmt>: 3301 subscript invalid r(3301) when rdplot in nested loopHi Community, I'm writing a nested Loop with Stata, the Variable Cur is a numeric with label, and I …
Subscribe to:
Post Comments (Atom)
0 Response to Counting observations of nearest neighbours
Post a Comment