The help on -index- leaves me a bit ignorant.
I use this without knowing how it works:
gen oral = "OVYS" if index(stk,"OVYS")
replace oral = "MICROG" if index(stk, "MICROG")
replace oral ="FEMOD" if index(stk, "FEMOD")
replace oral = "LOGED" if index(stk, "LOGED")
Index 'returns the position' it finds the string'
The position of MICROG could be, say, 9th character to 14th in the
string and returns 9-14. How is this translated in a yes?
This function (and most of Stata's string functions) work exactly like
those in many programming languages, e.g. c or perl. Since you get a
positive return if the substring is found and a zero return if it is
not, if(index()) will be true if found, false if not found.