I want to check whether any employee_id appears in more than one office_id. (EG: whether employee_id 123 appears in BOTH office_id ABC and office_id DEF).
The following example code creates three ids: An office_id, an employee id that only appears in one office (employee_id_oneoffice), and an employee id that appears in two offices (employee_id_repeats).
What is an assert statement (or other test) I could run to make sure that employees only appear in one office? (i.e that employee_id_oneoffice would pass and employee_id_repeats would fail)
Code:
set seed 339910 clear set obs 100 gen office_id = round(_n, 20) gen employee_id_oneoffice = office_id + floor(runiform(1,4)) gen employee_id_repeats = round(_n, 5)
Thanks,
Daniel
0 Response to How to check whether an small id (eg: employee_id) appears in two or more different big ids (eg: office_id)?
Post a Comment