Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: search the dataset for a string value


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: search the dataset for a string value
Date   Mon, 23 Feb 2004 16:49:42 -0000

For "yes" and "no", read also "true" and "false" (or "not true"). 

One further reference is 

What is true and false in Stata?
http://www.stata.com/support/faqs/data/trueorfalse.html


Nick 
[email protected] 

Roger Newson replied to Paul O'Brien:

> >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?
> 
> 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.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index