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   "Friedrich Huebler" <fhuebler@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: finding a sequence of numbers within a numeric variable
Date   Sun, 31 Aug 2008 00:08:28 -0400

Michael,

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 |
     +-------+

Friedrich

On Sat, Aug 30, 2008 at 2:26 PM, Michael McCulloch <mm@pinest.org> wrote:
> Hello,
> 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/



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