Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Looping through entries in csv file


From   Ada Ma <heu034@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Looping through entries in csv file
Date   Mon, 13 Sep 2010 20:52:16 +0100

David - I think Gillian need to create a list of postcode sector to
identify the postcodes, so that they can be extracted from the address
strings variables.

UK postcodes - IIRC - can go from 5 to 7 letters long (8 if including
the space in the middle).  e.g. first part of centre of Birmingham
postcode is B1...  but you also have first sector which is 4 letters
long e.g. Aberdeen Foresterhill AB25, Newcastle city centre is NE1.
Your suggestion about pattern should work.  Only thing is that
sometimes people are sloppy with the number of spaces in the middle,
sometimes they put them in, sometimes they forget it, sometimes they
have two to three spaces in to make it pretty (so that B1 would align
with AB24).

As for county boundaries - I am not sure.  But as counties are
amalgamation of Local Authority Districts so they are pretty big, I'd
imagine any mismatch shouldn't be massive.


Gillian - If you can't do the transpose in one go, I guess you must be
using older versions of MS Office - are you using 2003?  The latest
version of Excel has no limit on column numbers... so if you can find
a friend using MS Office 2007 your transpose problem can be solved.

Yet another alternative is to use the -reshape- command in Stata.
Create two variables:

gen id = 1
gen year=_n
keep postcode id year
reshape postcode, i(id) j(year)

Now browse  your data and copy and paste the only line of data you
have into a do file.   Fiddly solution but one needs not learn
programming for it!




On Mon, Sep 13, 2010 at 5:53 PM, David Elliott <dcelliott@gmail.com> wrote:
> Once one has the postal district extracted from the address fields,
> why not just use it to merge with a file containing the districts and
> counties?  I'm not catching the reason to place everything in a
> global.
>
> I also need to ask a question about UK postal codes.  Are UK codes
> fully circumscribed by county boundaries?  In Canada the fist part of
> the postal code is called a "Forward sortation area" or FSA - The FSA
> where I work, for example is "B3J"  One FSA can serve a fairly large
> region and at least for us, that region can extend across county lines
> which plays holy hell with our use of them to place persons within a
> county boundary for statistical purposes.  It may be prudent to test
> your apparent assumption that codes don't cross county lines.
>
> DC Elliott
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>



-- 
Ada Ma
Research Fellow
Health Economics Research Unit
University of Aberdeen, UK.
http://www.abdn.ac.uk/heru/
Tel: +44 (0) 1224 555189
Fax: +44 (0) 1224 550926

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index