Statalist


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

Re: st: destringing a variable?


From   Ronan Conroy <rconroy@rcsi.ie>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: destringing a variable?
Date   Wed, 12 Sep 2007 16:45:05 +0100

On 12 Sep 2007, at 16:35, Ms. Marilyn Ibarra wrote:

However, my variable 'foreign_id' is constructed as follows:

firm foreign_id
1 5011x
1 5011x
1 5011x
2 0017
2 0017
2 0017
etc.

I guess the solution is to get rid of the 'x' part. Anyone know how I can easily do this so I am left with:

Yes. If you look at the help file for -destring- it says

destring_options         description
  ignore("chars")        remove specified non-numeric characters

So adding the option

. destring foreign_id, replace ignore("x")

will do exactly what you want.

P    Before printing, think about the environment
=================================
Ronan Conroy
rconroy@rcsi.ie
Royal College of Surgeons in Ireland
120 St Stephen's Green, Dublin 2, Ireland
+353 (0)1 402 2431
+353 (0)87 799 97 95





*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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