From | Roger Newson <[email protected]> |
To | [email protected] |
Subject | Re: st: search the dataset for a string value |
Date | Mon, 23 Feb 2004 16:21:03 +0000 |
At 16:07 23/02/04 +0000, Paul O'Brien wrote:
The help on -index- leaves me a bit ignorant.The -index()- function evaluates to zero if the second argument appears nowhere in the first argument. And -if- treats zero value as "no", and treats all nonzero numeric values (including negative and missing values) as "yes". See -help ifcmd- and -help if- for further references.
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?
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |