Hi everyone!
I am working on a project and have been stuck trying to figure out part of it. I've been googling and searching thru the forums and haven't found anything that works yet, but it is possible that is because I don't know the way to correctly describe in search terms what it is that I am trying to do. I can explain it better here, if anyone has any suggestions on code to use or can point me in the right direction.
The dataset I am using is a set of traffic citations issued. One variable is 'officercode' and another variable is the 'dor_code' (which refers to the municipality the ticket was issued in). I am trying to determine the percent of officers that issued tickets in multiple municipalities (i.e. outside of their home municipality). To do so, I need to count the number of times that 'officercode' is listed in the dataset with more than one 'dor_code'. Here's a small example:
officercode dor_code
10 1
10 1
10 2
10 1
20 2
20 2
20 2
30 3
30 4
30 4
Based on this example, 2 of the 3 officers have issued tickets outside of their home municipality (i.e. 'officercode' 10 and 30 are both associated with 2 different 'dor_code' ).
I don't need to calculate the number of times that tickets were issued outside of their home municipality, just the number of officers. So my code needs to count the number of 'officercode' that are associated with more than one 'dor_code'.
Thanks in advance for any help!!
I am working on a project and have been stuck trying to figure out part of it. I've been googling and searching thru the forums and haven't found anything that works yet, but it is possible that is because I don't know the way to correctly describe in search terms what it is that I am trying to do. I can explain it better here, if anyone has any suggestions on code to use or can point me in the right direction.
The dataset I am using is a set of traffic citations issued. One variable is 'officercode' and another variable is the 'dor_code' (which refers to the municipality the ticket was issued in). I am trying to determine the percent of officers that issued tickets in multiple municipalities (i.e. outside of their home municipality). To do so, I need to count the number of times that 'officercode' is listed in the dataset with more than one 'dor_code'. Here's a small example:
officercode dor_code
10 1
10 1
10 2
10 1
20 2
20 2
20 2
30 3
30 4
30 4
Based on this example, 2 of the 3 officers have issued tickets outside of their home municipality (i.e. 'officercode' 10 and 30 are both associated with 2 different 'dor_code' ).
I don't need to calculate the number of times that tickets were issued outside of their home municipality, just the number of officers. So my code needs to count the number of 'officercode' that are associated with more than one 'dor_code'.
Thanks in advance for any help!!
Comment