Dear Statalist,
I am having some issues trying to create two count variables in a systematic way using loops. The first count variable (correct) should count, for each student, the number of correct answers while the second (incorrect) should count the number of incorrect answers out of a series of 9 binary variables. To be more precise, below is a sample of my data, which shows students' responses to two questions that assess their knowledge of local authorities' definition and missions.
In this dataset:
saying yes (=1) is correct for the variables local_auth_def_3 local_auth_mission_2 local_auth_mission_3 local_auth_mission_4 local_auth_mission_5
saying yes (=1) is incorrect for the variable local_auth_def_1 local_auth_def_2 local_auth_mission_1 local_auth_mission_6
Many thanks in advance for your help,
Guyle
I am having some issues trying to create two count variables in a systematic way using loops. The first count variable (correct) should count, for each student, the number of correct answers while the second (incorrect) should count the number of incorrect answers out of a series of 9 binary variables. To be more precise, below is a sample of my data, which shows students' responses to two questions that assess their knowledge of local authorities' definition and missions.
In this dataset:
saying yes (=1) is correct for the variables local_auth_def_3 local_auth_mission_2 local_auth_mission_3 local_auth_mission_4 local_auth_mission_5
saying yes (=1) is incorrect for the variable local_auth_def_1 local_auth_def_2 local_auth_mission_1 local_auth_mission_6
Many thanks in advance for your help,
Guyle
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(studentid local_auth_def_1 local_auth_def_2 local_auth_def_3 local_auth_mission_1 local_auth_mission_2 local_auth_mission_3 local_auth_mission_4 local_auth_mission_5 local_auth_mission_6) 1 1 0 0 0 0 0 1 0 0 2 1 0 1 0 1 1 0 0 1 3 0 1 0 0 1 0 1 1 1 4 1 0 0 0 0 1 1 0 1 5 0 1 0 0 0 0 0 1 1 6 0 1 0 1 1 0 1 1 0 7 1 0 0 0 1 0 0 1 1 8 0 1 0 1 0 0 1 0 0 9 1 1 1 0 1 1 0 1 0 10 0 1 0 1 1 1 0 0 0 11 0 0 0 0 1 0 0 0 0 12 1 1 1 0 0 0 1 0 1 13 1 1 0 0 1 0 1 1 1 14 0 0 0 1 1 1 1 1 1 15 1 0 0 1 1 1 1 1 0 16 1 1 1 1 1 0 1 0 0 17 1 1 1 1 0 1 1 0 0 18 0 1 1 0 1 1 0 0 1 19 1 1 1 0 1 1 1 1 0 20 0 1 0 0 0 0 0 1 0 21 0 1 0 1 1 1 0 0 1 22 1 0 1 1 1 0 0 0 0 23 1 1 1 1 0 1 0 0 0 24 0 1 1 0 0 1 0 0 1 25 0 0 0 0 1 0 0 0 0 end
Comment