Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: Removing trailing letter from string


From   "David Harrison" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Removing trailing letter from string
Date   Fri, 25 Feb 2005 13:11:39 -0000

Now the discussion has moved onto upper/lower case letters, I feel I should point out that my suggestion below strips off anything that is not a digit between 0 and 9 - this may or may not be beneficial depending on the situation, but in the case of valid postcodes it should be irrelevant!

David

-----Original Message-----
From: David Harrison 
Sent: 25 February 2005 12:44
To: [email protected]
Subject: st: RE: Removing trailing letter from string


. gen newv=cond(real(substr(v,-1,1))==., substr(v,1,length(v)-1), v)

. li

     +-------------+
     |    v   newv |
     |-------------|
  1. | EC4A    EC4 |
  2. | EC4P    EC4 |
  3. | EC4Y    EC4 |
  4. | DA15   DA15 |
  5. | SE10   SE10 |
     |-------------|
  6. |  SE2    SE2 |
  7. |  SE3    SE3 |
  8. |  W1A     W1 |
     +-------------+

Hope this helps

David

-----Original Message-----
From: Paul O'Brien [mailto:[email protected]]
Sent: 25 February 2005 12:36
To: [email protected]
Subject: st: Removing trailing letter from string


How do I remove the last letter from a string which ends with a letter but does nothing if the string ends in a digit? The string is either 3 or 4 characters long: 


EC4A 
EC4P 
EC4Y 
DA15 
SE10 
SE2 
SE3 
W1A 


Thanks 


Paul 
Dr Paul O'Brien 
Westside Contraceptive Services 
Raymede Clinic, Exmoor St, London 
W10 6DZ 
020 8962 4450 - tel 
020 8962 4451 - fax 
07900 495 118 - mob


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