replace postcode
= substr(postcode,1,length(postcode)-1)
if inrange(substr(postcode,-1,1), "A","Z")
This assumes no rogue "a" through "z" in
last position. Check for that
. assert !inrange(substr(postcode,-1,1), "a","z")
Nick
[email protected]
Paul O'Brien (modulo non-ASCII mailjunk)
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
*
* 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/