Good afternoon,
I use Stata SE/14.
My survey and subsequent data set (n=2,682) contains five string variables that include four "check all that apply" response options. For example, "In the last month, which of the following behaviors have you witnessed by community members in your neighborhood?" Respondents could select one, or up to all responses. Because we didn't include a "don't know" option in the original survey, such responses were added in later, by hand, during data entry in excel. These variables were all stored as string. This means I have variables that look, for example, like this:
VAR X Freq.
1 | 523
1,2 | 34
1,2,3 | 10
1,2,3,4 | 3
1,2,4 | 2
1,3 | 44
1,3,4 | 32
Don't know| 8
Not sure | 6
N/A | 3
No answer | 2
Because of the fact that the responses are both numeric and nonnumeric, and contain multiple values per cell, I am not sure where to start in terms of recoding such variables. I have tried the following commands:
destring VARX, generate(VARX_n)
But received the response VARX contains nonnumeric characters; no generate
I then tried
generate VARX_n=1
replace VARX_n=1 if VARX==1
and obtained the response:
type mismatch
r(109);
Is there another way to do this?
Thank you in advance for your assistance,
Florence
I use Stata SE/14.
My survey and subsequent data set (n=2,682) contains five string variables that include four "check all that apply" response options. For example, "In the last month, which of the following behaviors have you witnessed by community members in your neighborhood?" Respondents could select one, or up to all responses. Because we didn't include a "don't know" option in the original survey, such responses were added in later, by hand, during data entry in excel. These variables were all stored as string. This means I have variables that look, for example, like this:
VAR X Freq.
1 | 523
1,2 | 34
1,2,3 | 10
1,2,3,4 | 3
1,2,4 | 2
1,3 | 44
1,3,4 | 32
Don't know| 8
Not sure | 6
N/A | 3
No answer | 2
Because of the fact that the responses are both numeric and nonnumeric, and contain multiple values per cell, I am not sure where to start in terms of recoding such variables. I have tried the following commands:
destring VARX, generate(VARX_n)
But received the response VARX contains nonnumeric characters; no generate
I then tried
generate VARX_n=1
replace VARX_n=1 if VARX==1
and obtained the response:
type mismatch
r(109);
Is there another way to do this?
Thank you in advance for your assistance,
Florence