Statalist The Stata Listserver


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

Re: st: Data management: code to be able to..


From   Philipp Rehm <[email protected]>
To   [email protected]
Subject   Re: st: Data management: code to be able to..
Date   Sun, 03 Jun 2007 17:29:36 -0300

If your data look like you describe, this should work:

gen idcode=real(substr(id,-3,3))

HTH,
Philipp

S J wrote:
Dear all,

I have a string identifier variable of the form:

id
"LOCALITY_NAMED_ABCD 001"
"LOCALITY_NAMED_F 060"
"HOUSTON 078"
"SAN ANTONIO 112"

The variable id thus has both the name of the locality
in question (say, HOUSTON), and an identifying code
(say, 078).

How can I generate a new variable, idcode, that only
captures the numeric component of id, so that, I get,
for the above 4 cases, the values below:

idcode
1
60
78
112

Thanks for your advice.

Solange.


____________________________________________________________________________________
Now that's room service! Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097
*
* 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/

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index