Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
"Jesper Lindhardsen" <[email protected]> |

To |
<[email protected]> |

Subject |
st: RE: -inlist()- tip |

Date |
Wed, 13 Apr 2011 08:32:03 +0200 |

```
This is indeed brilliant! I, for one, did not think of -inlist- in this
way, however simple and (potentially) obvious.
Cheers & thanks,
Jesper
Jesper Lindhardsen
MD, PhD candidate
Department of Cardiovascular Research
Copenhagen University Hospital, Gentofte
Denmark
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: 12 April 2011 21:08
To: [email protected]
Subject: st: -inlist()- tip
Musing about -inlist()- reminded me of an application that was
certainly omitted from
SJ-6-4 dm0026 . . . . . . Stata tip 39: In a list or out? In a range
or out?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N.
J. Cox
Q4/06 SJ 6(4):593--595 (no
commands)
tip for use of inlist() and inrange()
but which I've seen somewhere previously, perhaps on the list.
-inlist()- is perhaps best known for examples like
... if inlist(rep78, 3, 4, 5)
which can be thought of as equivalent to
... if rep78 == 3 || rep78 == 4 || rep78 == 5
However, consider also this
... if inlist(1, a, b, c, d, e)
which can be thought of as equivalent to
... if 1 == a | 1 == b | 1 == c | 1 == d | 1 == e
which in practice (mathematics schooling?) most of us would be more
likely to write
... if a == 1 | b == 1 | c == 1 | d == 1| e == 1
but that difference is immaterial.
If all this was already utterly obvious to you beforehand, my
apologies (or congratulations), but I've been wondering why this was
not obvious to me beforehand. I think it was because I had
internalised -inlist()- in terms of one application, whether a
variable was equal to one of a list of values, and was usually
thinking of it in that verbal form. (The Tip referred to above goes a
bit further.) Thus I missed the elementary algebra that if a variable
is equal to a value then that value is also equal to that variable.
There may be a few others who will be happy to discard that small
mental block.
Nick
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
```

**References**:**st: -inlist()- tip***From:*Nick Cox <[email protected]>

- Prev by Date:
**Re: st: Imposing a line graph into a bar graph** - Next by Date:
**Re: st: Imposing a line graph into a bar graph** - Previous by thread:
**st: -inlist()- tip** - Next by thread:
**st: comparison of means** - Index(es):