[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: search the dataset for a string value
On Feb 24, 2004, at 2:33 AM, Paul wrote:
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.
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?
* For searches and help try: