Hello everyone,
I am working with a large dataset (4,682 variables, 5,726 observations) of students attending U.S. schools. Essentially, I want to limit the data to have students who experienced bullying or cyberbullying during the school year. Thus, I only want to count students who answered "yes" (coded 1) to any of the seven particular bullying-related or cyberbullying-related questions and exclude those not bullied from the dataset.
I used the generate command to construct a variable with the value 1 if the value of the various bullying variables is equal to 1 and did the same thing for cyberbullying.
Total=1,017
Total=330
Total: 253
However, I do not know how to continue with restricting the data to have the sample of 1,094 students who experienced bullying, cyberbullying, or both.
I tried using these commands
and
However, they end up deleting all cases other than those that said "yes" to the variable in question, which is a problem if a respondent said "yes" to more than one variable meaning that they encountered multiple bullying behaviors. Is there a way to sum all the "yes" responses for each of the variables listed above to create a new dataset?
Many thanks for considering my request.
I am working with a large dataset (4,682 variables, 5,726 observations) of students attending U.S. schools. Essentially, I want to limit the data to have students who experienced bullying or cyberbullying during the school year. Thus, I only want to count students who answered "yes" (coded 1) to any of the seven particular bullying-related or cyberbullying-related questions and exclude those not bullied from the dataset.
I used the generate command to construct a variable with the value 1 if the value of the various bullying variables is equal to 1 and did the same thing for cyberbullying.
Code:
gen bullyvic=1 if VS0073==1|VS0074==1|VS0075==1|VS0076==1|VS0077==1|VS0078==1|VS0079==1
Code:
tab bullyvic
Code:
gen cyberbullyvic=1 if VS0097==1|VS0156==1|VS0098==1|VS0099==1|VS0100==1|VS0101==1|VS0102==1
Code:
tab cyberbullyvic
Code:
tab bullyvic cyberbully
However, I do not know how to continue with restricting the data to have the sample of 1,094 students who experienced bullying, cyberbullying, or both.
I tried using these commands
Code:
drop if
Code:
keep if
Many thanks for considering my request.
Comment