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

RE: st: RE: Removing trailing letter from string


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Removing trailing letter from string
Date   Fri, 25 Feb 2005 13:09:06 -0000

Good detail. Thanks. 

Accents are not part of British postcodes, so worry 
about data pathologies need mot morph into paranoia. 

Nick 
n.j.cox@durham.ac.uk 

Seb Buechte
 
> Well, if you do not know, wether all letters capitalized, this
> modification may workout for you, it is basically adding the upper()
> function:
> 
> replace postcode
>        = substr(postcode,1,length(postcode)-1)
>        if inrange(upper(substr(postcode,-1,1)), "A","Z")
> 
> The upper() function will not work for letters like "" or "" with a
> ASCII code > 122.

Nick Cox 

> > 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
> > n.j.cox@durham.ac.uk
> > 
> > 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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index