******************************************************* *This do file is a solution to the Linking Possibilites *exercise from the 2018 IPUMS-CPS Summer Data Workshop * *Written by the IPUMS-CPS team *31 May 2018 ******************************************************* qui{ cap log close log using logs/01_linking_possibilities.log, t replace clear set more off //Questions 1-3 of this exercise will be answered with the cps rotation exploration station //veterans and volunteers data (questions 4-7) cd data qui do cps_00193.do numlabel , add // show that the original data is unsorted noisily: di "...now we have IPUMS data ready to go" noisily:list cpsidp mish age sex in 1/10 noisily: di "...now we need to sort the data by CPSIDP and month-in-sample" noisily: di "...and generate a new variable to indicate how many times an individual appears in the data" bysort cpsidp (mish) : gen time = _n noisily: list cpsidp mish age sex time in 1/10 noisily: di "...now we need to create a variable to indicate the maximum number of times an individual appears in the data" egen count=max(time),by(cpsidp) noisily: list year month time in 1/10 noisily: tab count month, col //drop non-links noisily: di "...we only want to retain the successful links (that is those that appear two times)" noisily: drop if count==1 //find mis transitions noisily: di "...the month-in-sample by month breakdown shows the 75% overlap of rotation groups across months" noisily: tab mish month noisily: di "...because there are only two months in this linking scenario, assigning the maximum mish value" noisily: di "to the variable next_mish, we can see the individuals progression through the rotation pattern" egen next_mis = max(mish),by(cpsidp) noisily: tab mish next_mis if time==1, missing clear //now the 8-month panel (11-12) noisily: di "...now read in the data for the 8-month panel" qui do cps_00224.do noisily: di "...count those entering the rotation in August 2015" noisily: count if year==2015 & month==8 & mish==1 //flag those who enter the rotation in august 2015 noisily: di "...generate a flag for those records entering the rotation in August 2015" gen enter_aug = 1 if year==2015 & month==8 & mish==1 replace enter_aug = 0 if enter_aug==. noisily: list cpsidp month mish age sex enter_aug in 1/10 //count those who enetered in august and also have an mish value of 8 //this also counts people who enter in august and exit and re-enter noisily: di "...create a flag for those who entered in August" egen _aug_entrant = max(enter_aug),by(cpsidp) noisily: list cpsidp month mish age sex enter_aug _aug_entrant in 1/10 noisily: di "...now count the number of persons who entered in August and appear in the final interview" noisily: count if mish==8 & _aug_entrant==1 noisily: di "...(note that this number includes those who enter in August, exit, and then re-enter the survey due to nonresponse in one or more months)" log close cd .. }