Statalist


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

RE: st: finding a sequence of numbers within a numeric variable


From   Michael McCulloch <mm@pinest.org>
To   statalist@hsphsun2.harvard.edu
Subject   RE: st: finding a sequence of numbers within a numeric variable
Date   Mon, 1 Sep 2008 06:33:02 -0700

Excellent! I like the efficiency of this inlist code.

Another solution is

... if inlist(var, 8070, 80703)

Nick
n.j.cox@durham.ac.uk

Friedrich Huebler

I assume the variable is in numeric format.

. list

     +-------+
     |   var |
     |-------|
  1. |  8070 |
  2. | 80703 |
  3. |  8071 |
     +-------+

. list if substr(string(var),1,4)=="8070"

     +-------+
     |   var |
     |-------|
  1. |  8070 |
  2. | 80703 |
     +-------+

On Sat, Aug 30, 2008 at 2:26 PM, Michael McCulloch <mm@pinest.org>
wrote:


 If I have a variable that contains:
        8070
        80703
        8071
 is it possible to define an -if- statement that will give me
        8070
        80703
 but not
        8071
 ?
*
*   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/



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