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

Re: st: RE: RE: RE: Removing trailing letter from string


From   Seb Buechte <[email protected]>
To   [email protected]
Subject   Re: st: RE: RE: RE: Removing trailing letter from string
Date   Fri, 25 Feb 2005 15:26:51 +0100

Nick,

what do you exactly mean. Checking for the validity in terms of  a
code fullfilling the requirements of a certain nations postcodes e.g.
German postcodes contain only 5 digits. Or do you mean checking wether
a specific code does not only look like a postcode but is also a real
one?

Sebastian



On Fri, 25 Feb 2005 13:21:52 -0000, Nick Cox <[email protected]> wrote:
> Quite so.
> 
> This raises an interesting question of
> how to check (British or indeed any other)
> postcodes. Given various possibilities it
> would not be trivial, but I believe Stata provides
> all the rudimentary handles.
> 
> Nick [home postcode DH1 2NJ]
> [email protected]
> 
> David Harrison
> 
> > 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 Harrison
> 
> > . 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 |
> >      +-------------+
> >
> 
> *
> *   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/
> 


-- 
- Seb F Buechte
-
- Stay tuned!
*
*   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