Dear All,
I want to generate indicator variables from string variable q26_name_ghfac which contains 1,2,3,....,14 separated by comma. Indicator variables are expected to be like scheme_1, scheme_2...scheme_14 indicating 1 for presence of the no in q26_name_ghfac, 0 therwise.
I tried split q26_name_ghfac, gen(scheme_) p(,) but failed to achieve desired result.
Data is
Thanks in advance
I want to generate indicator variables from string variable q26_name_ghfac which contains 1,2,3,....,14 separated by comma. Indicator variables are expected to be like scheme_1, scheme_2...scheme_14 indicating 1 for presence of the no in q26_name_ghfac, 0 therwise.
I tried split q26_name_ghfac, gen(scheme_) p(,) but failed to achieve desired result.
Data is
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str10 q26_name_ghfac "1" "1" "1,10" "6" "" "7,11,12,13" "" "11,12,13" "6,12,13" "12,13" "12,13" "1" "" "14" "1" "14" "14" "" "" "1,10" "" "" "" "" "" "" "" "" "" "" "" "" "6" "1" "" "" "" "" "" "10" "" "" "6" "1" "" "" "" "" "" "10" "" "" "" "" "10" "" "" "6" "1" "" "" "" "6" "1" "" "12" "12" "12" "" "" "14" "" "10" "" "" "" "" "14" "6" "1" "" "13" "" "5,12,13" "" "" "" "6" "1,5,8,14" "" "1,5,14" "" "" "" "" "" "" "" "13" "10" end
Thanks in advance
Comment