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
Reshape to Long-Firm Year Panel - Data in Multiple excel files and multiple worksheetsHi, I'm quite new to Stata so I am in a bit of a pickle. I need to get a long format firm-year pane…
Aidsills with market fixed effectsDear Statalisters, I am using Stata ver 14, and the built in command aidsills written by Lecocq and…
spatial econometricsHi everyone Someone knows how to run the LMlambda, LMlambda ROBUST LMrho LMrho ROBUST ? What is co…
Lagged variables of daily dataHi, I have a dataset of stock returns, with daily returns (panel). I have successfully created runn…
Simple info on combomarginsplotDear Stata users, I would like to know whether there is an option of combomarginsplot that allows m…
Subscribe to:
Post Comments (Atom)
0 Response to Counting observations of nearest neighbours
Post a Comment