Dear all,
using an individuals nested in schools dataset, I am trying to create a dataset with the peers or peers which meet the following condition: the primary school (ks2) peers’ of the secondary school (ks4) peers, who attended a different primary school than that of the individual of interest.
In this toy example case 6 is a relevant peer of peer for the peers 3, 4, 5, which in turn are the relevant peers for individuals 1 and 2.
How do I create an extra column that indicates if the peers of peers condition is met? I think this requires creating additional datasets with different variables names and then merging them, but my attempts do not seem to work.
Any help is much appreciated, Nic
using an individuals nested in schools dataset, I am trying to create a dataset with the peers or peers which meet the following condition: the primary school (ks2) peers’ of the secondary school (ks4) peers, who attended a different primary school than that of the individual of interest.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(id ks2perf) str1(ks4_school_id ks2_school_id) 1 14 "a" "b" 2 11 "a" "b" 3 9 "a" "c" 4 17 "a" "c" 5 22 "a" "c" 6 1 "d" "c" 7 18 "d" "b" end
How do I create an extra column that indicates if the peers of peers condition is met? I think this requires creating additional datasets with different variables names and then merging them, but my attempts do not seem to work.
Any help is much appreciated, Nic
Comment