Statalist


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

Re: st: Extracting Numbers from Strings


From   Robert A Yaffee <[email protected]>
To   [email protected]
Subject   Re: st: Extracting Numbers from Strings
Date   Wed, 24 Dec 2008 14:48:08 -0500

Jason,
  gen y = substr(x,1,1)
  destring y, replace
    should do it.
         Robert

Robert A. Yaffee, Ph.D.
Research Professor
Silver School of Social Work
New York University


Biosketch: http://homepages.nyu.edu/~ray1/Biosketch2008.pdf

CV:  http://homepages.nyu.edu/~ray1/vita.pdf

----- Original Message -----
From: [email protected]
Date: Wednesday, December 24, 2008 2:27 pm
Subject: st: Extracting Numbers from Strings
To: "[email protected]" <[email protected]>


> I'm trying to extract the first number after a hyphen.
> For example, from x="1234-1" I want to create y=1.
> Thanks.
> 
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index