Hello all,
I have used -tabstat- to identify if an individual had performed a certain action multiple times. If the result is 1, I would would like to keep the data from the person; if the person has more that 1, I would like to remove them from the data set. Is there way do this or would I have to do this manually?
I am using stata 15.0 for Windows.
For extra information, I am using panel data to see the effects that the act of internal migration has on a person's subjective well being. I was having trouble with individuals that moved multiple times so I decided to look at individuals that moved either once or not all.
I used
to find out how many times an individual moved.
To clarify variables: pid = person identification, movest = mover status, M0 = if they moved ( I created M0 by)
This is an example of my data:
Thank you for the help.
I have used -tabstat- to identify if an individual had performed a certain action multiple times. If the result is 1, I would would like to keep the data from the person; if the person has more that 1, I would like to remove them from the data set. Is there way do this or would I have to do this manually?
I am using stata 15.0 for Windows.
For extra information, I am using panel data to see the effects that the act of internal migration has on a person's subjective well being. I was having trouble with individuals that moved multiple times so I decided to look at individuals that moved either once or not all.
I used
tabstat M0,statistic( sum )by(pid)
To clarify variables: pid = person identification, movest = mover status, M0 = if they moved ( I created M0 by)
gen M0 = (movest==2)
This is an example of my data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long pid byte movest float M0 10007857 4 0 10007857 1 0 10007857 1 0 10007857 1 0 10014578 1 0 10014578 1 0 10014578 1 0 10014578 1 0 10014578 1 0 10014578 1 0 10014578 1 0 10014578 1 0 10014578 1 0 10014578 2 1 10014578 1 0 10014608 1 0 10014608 1 0 10014608 1 0 10014608 1 0 10014608 1 0 10014608 1 0 10014608 1 0 10014608 1 0 10014608 1 0 10014608 2 1 10014608 1 0 10016813 1 0 10016813 1 0 10016813 1 0 10016813 1 0 10016813 1 0 10016813 1 0 10016848 2 1 10016848 1 0 10016848 1 0 10016848 1 0 10016848 1 0 10016848 1 0 10016848 1 0 10016848 1 0 10016848 1 0 10016848 1 0 10016848 1 0 10016848 1 0 10016872 1 0 10016872 1 0 10016872 1 0 10016872 1 0 10016872 1 0 10016872 1 0 10016872 1 0 10016872 1 0 10016872 1 0 10016872 1 0 10016872 2 1 10017933 1 0 10017933 1 0 10017933 1 0 10017933 1 0 10017933 1 0 10017933 1 0 10017933 1 0 10017933 1 0 10017933 1 0 10017933 1 0 10017933 1 0 10017933 1 0 10017933 1 0 10017992 1 0 10017992 1 0 10017992 1 0 10017992 1 0 10017992 1 0 10017992 1 0 10017992 1 0 10017992 1 0 10017992 1 0 10017992 1 0 10017992 1 0 10017992 1 0 10019057 2 1 10019057 1 0 10019057 1 0 10019057 1 0 10019057 1 0 10019057 1 0 10019057 1 0 10019057 1 0 10019057 1 0 10019057 1 0 10019057 1 0 10019057 1 0 10019057 1 0 10023526 1 0 10023526 1 0 10023526 1 0 10023526 1 0 10023526 1 0 10023526 1 0 10023526 1 0 end label values movest fmovest label def fmovest 1 "non-mover", modify label def fmovest 2 "mover within gb", modify label def fmovest 4 "mover back to gb", modify
Comment