Hi, I'm trying to calculate the following leave one out mode: I have data on student postcode of residence and their school code. For each student I want to find the modal postcode of all students in their school except that particular student. I followed the solution given in this thread.
The code I used:
But I get error r(198): "N not found invalid syntax"
Would appreciate any help.
Thanks,
The code I used:
Code:
gen modal_pcd=. gen value_pcd=. forvalues i=1/ `=N' { replace value_pcd = cond (school == school [`i'] & _n!= `i', postcode, .) egen tempmode=mode (value_pcd), minmode replace modal_pcd = tempmode in `i' drop tempmode
Would appreciate any help.
Thanks,
Comment