Stata 選舉變數
1. winning margins: 第一得票者與第二得票者之間的vote_ratio差異
sort district
*(從小到大排序)
bys district (vote_ratio): gen margin = vote_ratio[_N] - vote_ratio[_N-1]
I sort by district and vote_ratio, and then within each district, compute the difference between the largest vote_ratio and the vote_ratio
a. _N: the total number of observations within the district
b. vote_ratio[_N]: is the last observation within the district
c. vote_ratio[_N-1]: the second last observation within the district
Free Stata lectures and notes
1) LEMMA (需要註冊)
2) UCLA lab
Comments
Post a Comment