Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: alt to inlist?

From   "Nick Cox" <>
To   <>
Subject   st: RE: alt to inlist?
Date   Mon, 23 Jan 2006 22:36:33 -0000

I don't know which FAQ you are referring to. 

It might be

which points to

which suggests a solution based on -merge-. On 
the information provided, that sounds like the nicest

The statement that -inlist()- 

"doesn't like it when one of the arguments in the list doesn't exist"

is in my experience false. And in principle I don't believe it! 
My guess is that you are getting mixed up between literal 
strings and names of string variables. 

. sysuse auto 
(1978 Automobile Data)

. l make if inlist(word(make,1), "Ford", "Reagan", "Clinton", "Bush", "any one else") 

     | make         |
 24. | Ford Fiesta  |
 25. | Ford Mustang |


Danielle H. Ferry

> Is there something like inlist which does not require that 
> all arguments
> exist? I would like to keep observations where varname = a or 
> b or c or d or
> ... But  it could be that varname never takes the value of d. 
> Another issue is
> that my list of arguments is v. long (~145), so a simple or 
> statement is not
> possible. I found a stata faq that suggested using inlist, 
> but this doesn't
> like it when one of the arguments in the list doesn't exist, 
> and my varname is
> a string, so I'd have to write many of these inlist 
> statements (b/c the limit
> is 10). 

*   For searches and help try:

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