I am trying to generate an indicator called mo_all using egen and concat that records all the unique values across a set of variables mo#. Specifically, my code is egen mo_all = concat(mo1_1 mo2_1 mo3_1 mo4_1 mo5_1 mo6_1 mo7_1 mo8_1 mo9_1 mo10_1 mo11_1 mo12_1 mo13_1 mo14_1 mo15_1 mo16_1), punct(" ")
In this new indicator, I'd like to record only unique values across the variables. For example, in the table below, mo_all in row 1 would equal "1 2 3 4 5", in row 2 it would equal "6 7 8 9", and in row 3 it would equal "10 11".
My current code records every value, so row 2 equals "6 7 7 8 9"
mo1 | mo2 | mo3 | mo4 | mo5 |
1 | 2 | 3 | 4 | 5 |
6 | 7 | 7 | 8 | 9 |
10 | 10 | 10 | 11 | 11 |
12 | 13 | 14 | 15 | 16 |
Thank you for your time and help!
Tom
0 Response to keeping only unique values using egen concat
Post a Comment