Code:
* Example generated by -dataex-. For more info, type help dataex clear input float id str35 item 1 "11,12" 2 "4,13" 4 "1,2,5" 83 "1,4,8,10" 107 "1,2,8,15" 143 "1,2" 161 "1,4,5,6,8,11,12" end
I want to create 15 variables called item_1, item_2, .... until item_15 which have value 1 when the string variable "item" includes the value number of the variable's name. For instance,
id1, item_11=1, item_12=1
id2, item_4=1, item_13=1
id4, item_1=1, item_2_=1, item_5=1
etc.
I have tried to use the command regexm as below with no success
foreach x in 1/15 {
generate item_`x' = regexm(item,"`x'")
}
Anyone could help me, please?
Comment