Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Formatting a string variable (UK postcodes) to always be seven characters in length


From   Roberto Ferrer <[email protected]>
To   Stata Help <[email protected]>
Subject   Re: st: Formatting a string variable (UK postcodes) to always be seven characters in length
Date   Tue, 4 Feb 2014 11:21:25 -0430

Catherine,

I believe you need a set of rules before figuring out the Stata
syntax. If the postcode has 8 characters, which one do you delete? If
it has 5, what do you add? And so on...

On Tue, Feb 4, 2014 at 11:13 AM,  <[email protected]> wrote:
> Good afternoon
>
> I'm hoping someone can help me with a formatting issue with regard to UK
> postcodes whereby I want to create a new postcode variable that is always
> seven characters in length from a postcode variable that has between five
> and eight characters (e.g. 7 numbers/letters with a space = 8).  I want to
> ultimately join my cleaned postcode variable created in Stata to a postcode
> shapefile in ArcGIS.  The postcode shapefile variable is always seven
> characters in length, with various combinations of letters, numbers and
> spaces, e.g.
>
> LN  NLL
> LLN NLL
> LNN NLL
> LLNNNLL
> LLNLNLL
> LNL NLL
>
> Where L represents a letter and N a number.  I need to clean my original
> postcode variable as there is little consistency (e.g. LN  NLL (two spaces)
> vs LNNLL (no space) vs LN NLL (one space).
>
> Are there any suggestions on how I can create a new postcode variable in
> Stata that is always seven characters in length bearing in mind that if a
> space/s is required, there always needs to be three characters at the end
> after the split?  I hope this all makes sense?!
>
> I'm using Stata 12.1, any help much appreciated.
>
> Many thanks
> Catherine
>
>
>
> --
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index