I am looking at the effects of the Affordable Care Act on the job mobility of young adults using CPS data, looking at the variable EMPSAME, which indicates whether or not the respondent was employed by the same employer and the same job he/she reported working as his/her main job in the previous month's survey.
Right now, I have the data all in one big dataset, and am curious at looking at the change in responses to EMPSAME across the first four "waves" (defined as MISH in the dataset (month in sample household)) of a survey. I have the variables as shown below along with some demographic variables such as state, race, education, and marital status that have all been modified such that the response in the first wave remains the same for the three subsequent waves.
How can I parse the dataset by waves such that I can then merge them back and have the dataset sorted by CPSIDP and have the responses to EMPSAME all in one row? Would it make sense to make a variable denoting the change in responses to EMPSAME before the parsing or once I have remerged the dataset (I just need to know if there was a change from "Yes" to "No" or "NIU" within those four waves for each participant). The "1" (No) response to EMPSAME exists, it's just not in this sample from the dataset, not sure if that would matter.
For the parsing part, I am very new to loops so I tried the following but keep getting an invalid name error that I haven't been able to figure out:
Furthermore, there are responses in which a person does not show up for all four waves, will that conflict with the parsing & merge, and if so, how can I drop those observations from the dataset?
Any help is much appreciated. Thanks!
Right now, I have the data all in one big dataset, and am curious at looking at the change in responses to EMPSAME across the first four "waves" (defined as MISH in the dataset (month in sample household)) of a survey. I have the variables as shown below along with some demographic variables such as state, race, education, and marital status that have all been modified such that the response in the first wave remains the same for the three subsequent waves.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int year byte(month mish age) double cpsidp byte empsame 2008 1 1 25 20080100006601 99 2008 2 2 25 20080100006601 2 2008 3 3 25 20080100006601 2 2008 4 4 25 20080100006601 2 2008 1 1 26 20080100006602 99 2008 2 2 27 20080100006602 2 2008 3 3 27 20080100006602 2 2008 4 4 27 20080100006602 2 2008 4 4 22 20080100006606 99 2008 1 1 16 20080100007203 99 2008 2 2 16 20080100007203 99 2008 3 3 16 20080100007203 99 2008 4 4 16 20080100007203 99 2008 1 1 21 20080100007204 99 2008 2 2 21 20080100007204 99 2008 3 3 22 20080100007204 99 2008 4 4 22 20080100007204 99 2008 1 1 18 20080100008002 99 2008 2 2 18 20080100008002 99 2008 3 3 18 20080100008002 99 2008 4 4 18 20080100008002 99 2008 1 1 19 20080100008003 99 2008 2 2 19 20080100008003 99 2008 3 3 19 20080100008003 99 2008 4 4 20 20080100008003 99 2008 1 1 21 20080100008004 99 2008 2 2 22 20080100008004 99 2008 3 3 22 20080100008004 99 2008 4 4 22 20080100008004 99 2008 1 1 30 20080100010701 99 2008 2 2 31 20080100010701 2 2008 3 3 31 20080100010701 2 2008 4 4 31 20080100010701 2 2008 1 1 26 20080100010702 99 2008 2 2 26 20080100010702 2 2008 3 3 27 20080100010702 2 2008 4 4 27 20080100010702 2 2008 1 1 32 20080100010703 99 2008 2 2 32 20080100010703 2 2008 3 3 32 20080100010703 2 2008 4 4 32 20080100010703 2 2008 1 1 20 20080100016703 99 2008 2 2 20 20080100016703 2 2008 3 3 20 20080100016703 2 2008 4 4 20 20080100016703 99 2008 1 1 22 20080100016704 99 2008 2 2 22 20080100016704 2 2008 3 3 22 20080100016704 99 2008 4 4 22 20080100016704 99 2008 1 1 18 20080100020104 99 2008 2 2 18 20080100020104 99 2008 1 1 32 20080100022101 99 2008 2 2 32 20080100022101 2 2008 1 1 16 20080100022605 99 2008 2 2 16 20080100022605 99 2008 3 3 16 20080100022605 99 2008 4 4 17 20080100022605 99 2008 2 2 19 20080100028903 99 2008 3 3 19 20080100028903 99 2008 4 4 19 20080100028903 99 2008 1 1 28 20080100032901 99 2008 2 2 29 20080100032901 2 2008 3 3 29 20080100032901 2 2008 4 4 29 20080100032901 2 2008 1 1 21 20080100033801 99 2008 2 2 22 20080100033801 2 2008 3 3 22 20080100033801 2 2008 4 4 22 20080100033801 2 2008 1 1 20 20080100033802 99 2008 1 1 26 20080100033803 99 2008 2 2 26 20080100033803 99 2008 3 3 26 20080100033803 99 2008 4 4 26 20080100033803 99 2008 3 3 20 20080100033804 99 2008 4 4 20 20080100033804 99 2008 1 1 20 20080100038203 99 2008 2 2 20 20080100038203 99 2008 3 3 20 20080100038203 99 2008 4 4 20 20080100038203 99 2008 1 1 23 20080100038801 99 2008 2 2 23 20080100038801 99 2008 3 3 23 20080100038801 99 2008 4 4 23 20080100038801 99 2008 1 1 28 20080100038802 99 2008 2 2 28 20080100038802 2 2008 3 3 28 20080100038802 2 2008 4 4 28 20080100038802 2 2008 3 3 16 20080100043102 99 2008 4 4 16 20080100043102 99 2008 1 1 18 20080100050902 99 2008 2 2 18 20080100050902 99 2008 1 1 29 20080100051101 99 2008 2 2 29 20080100051101 2 2008 3 3 29 20080100051101 2 2008 4 4 29 20080100051101 2 2008 1 1 32 20080100051102 99 2008 2 2 32 20080100051102 2 2008 3 3 32 20080100051102 2 2008 4 4 32 20080100051102 2 2008 1 1 32 20080100062001 99 end label values month month_lbl label def month_lbl 1 "January", modify label def month_lbl 2 "February", modify label def month_lbl 3 "March", modify label def month_lbl 4 "April", modify label values mish mish_lbl label def mish_lbl 1 "One", modify label def mish_lbl 2 "Two", modify label def mish_lbl 3 "Three", modify label def mish_lbl 4 "Four", modify label values age age_lbl label def age_lbl 16 "16", modify label def age_lbl 17 "17", modify label def age_lbl 18 "18", modify label def age_lbl 19 "19", modify label def age_lbl 20 "20", modify label def age_lbl 21 "21", modify label def age_lbl 22 "22", modify label def age_lbl 23 "23", modify label def age_lbl 25 "25", modify label def age_lbl 26 "26", modify label def age_lbl 27 "27", modify label def age_lbl 28 "28", modify label def age_lbl 29 "29", modify label def age_lbl 30 "30", modify label def age_lbl 31 "31", modify label def age_lbl 32 "32", modify label values empsame empsame_lbl label def empsame_lbl 2 "Yes", modify label def empsame_lbl 99 "NIU", modify
How can I parse the dataset by waves such that I can then merge them back and have the dataset sorted by CPSIDP and have the responses to EMPSAME all in one row? Would it make sense to make a variable denoting the change in responses to EMPSAME before the parsing or once I have remerged the dataset (I just need to know if there was a change from "Yes" to "No" or "NIU" within those four waves for each participant). The "1" (No) response to EMPSAME exists, it's just not in this sample from the dataset, not sure if that would matter.
For the parsing part, I am very new to loops so I tried the following but keep getting an invalid name error that I haven't been able to figure out:
Code:
forval i=1/4{ use bigdata.dta keep if mish=='i' sort cpsidp save data 'i'.dta
Any help is much appreciated. Thanks!
Comment