I am working on a variable that has been difficult to clean. Panel data, long format, Stata version 16.
The variable is a multiple response that opens up after the individual has responded to "yes".
So the question is "do you help your children?" Yes/No. When the individual selects "yes", then the multiple response opens, that's why the amount of individual responders is about half. The multiple response is from a question of "how much is the frequency you help your children", so the alternatives are in an ordinal structure from 1 to 4.
I need to eliminate all the missing variables from that and generate a dummy variable for each alternative (a dummy for response 1, a dummy for response 2, etc). But it has been hard to properly assess the missings. Whether they are missing because the person didn't want to continue responding or whether the individual didn't have more cases to select.
I have followed the tutorials and already have done this :
- First, I dropped the missing values of sp016_* , then I tried the following code
Code:
mrtab sp016_1 - sp016_10, include response (1) mrtab sp016_1 - sp016_10, include response (2) mrtab sp016_1 - sp016_10, include response (3) mrtab sp016_1 - sp016_10, include response (4)
Then I tried this,
Code:
egen has1 = anymatch(sp016_1 - sp016_10), values(1)
Then I followed with using
Code:
egen has_any = rowmax(has*) tabulate has_any has_any Freq. Percent Cum. 0 10 0.04 0.04 1 25,205 99.96 100.00 Total 25,215 100.00
Do you have any other idea or code to solve this? I need a dummy variable for each multiple response alternative. I also post the Dataex of my dataset
dataex sp016_1 - sp016_10
Code:
clear input byte(sp016_1 sp016_2 sp016_3 sp016_4 sp016_5 sp016_6 sp016_7 sp016_8 sp016_9 sp016_10) 3 . . . . . . . . . 2 . . . . . . . . . . 1 . . . . . . . . 2 2 . . . . . . . . 4 . . . . . . . . . 2 . . . . . . . . . 1 . . . . . . . . . 1 . . . . . . . . . 2 . . . . . . . . . . 2 . . . . . . . . . 2 . . . . . . . . 2 . . . . . . . . . . . . 4 . . . . . . 1 . . . . . . . . . . . . . 3 . . . . . . 2 . . . . . . . . . 4 . . . . . . . . 1 . . . . . . . . . 2 . . . . . . . . . 4 4 . . . . . . . . 2 . . . . . . . . . 4 . . . . . . . . . 1 . . . . . . . . . 3 . . . . . . . . . 2 . . . . . . . . . 1 1 . . . . . . . . . . 2 . . . . . . . 2 2 . . . . . . . . 2 . . . . . . . . . 2 . . . . . . . . . 3 3 . . . . . . . . 2 . . . . . . . . . 1 3 . . . . . . . . 1 . . . . . . . . . 1 . . . . . . . . . 1 . . . . . . . . . . . 1 . . . . . . . 2 . . . . . . . . . 1 . . . . . . . . . 1 . . . . . . . . . 4 . . . . . . . . . . 3 . . . . . . . . . 1 . . . . . . . . . . 4 . . . . . . . . 1 . . . . . . . . 4 . . . . . . . . . 3 . 2 . 2 . . . . . 1 1 . . . . . . . . . 4 . . . . . . . . . 2 2 . . . . . . . 1 . 1 . . . . . . . 3 . . . . . . . . . 2 . . . . . . . . . . 1 . . . . . . . . 4 . . . . . . . . . 4 . . . . . . . . . . 4 . . . . . . . . 2 . . . . . . . . . 1 . . . . . . . . . 3 3 . . . . . . . . . 2 . . . . . . . . 4 . . . . . . . . . 1 . 1 . . . . . . . 2 . . . . . . . . . . . 3 . . . . . . . 1 . . . . . . . . . . . 4 . . . . . . . 1 . . . . . . . . . . . 4 . . . . . . . . 2 . . . . . . . . 1 1 . . . . . . . . 2 . . . . . . . . . 1 . . . . . . . . . 2 . . . . . . . . . 2 4 . . . . . . . . . . 2 . . . . . . . 4 4 4 4 . . . . . . 4 . . . . . . . . . 2 . . . . . . . . . 4 . . . . . . . . . 2 2 . . . . . . . . 2 . . . . . . . . . 2 2 . . . . . . . . 4 2 . . . . . . . . . 4 . . . . . . . . . 4 . . . . . . . . 3 . . . . . . . . . 3 3 . . . . . . . . . 2 . . . . . . . . 1 1 . . . . . . . . 2 . . . . . . . . . 2 2 . . . . . . . . 2 . . . . . . . . . 2 . . . . . . . . . 4 . . . . . . . . . . . 2 . . . . . . . 3 . . . . . . . . . 4 . . . . . . . . . 2 . . . . . . . . . . 4 . . . . . . . . end label values sp016_1 howoftensp label values sp016_2 howoftensp label values sp016_3 howoftensp label values sp016_4 howoftensp label values sp016_5 howoftensp label values sp016_6 howoftensp label values sp016_7 howoftensp label values sp016_8 howoftensp label values sp016_9 howoftensp label values sp016_10 howoftensp label def howoftensp 1 "About daily", modify label def howoftensp 2 "About every week", modify label def howoftensp 3 "About every month", modify label def howoftensp 4 "Less often", modify
0 Response to Multiple response data cleaning
Post a Comment