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: RE: Looping through entries in csv file
From
[email protected]
To
[email protected]
Subject
Re: st: RE: Looping through entries in csv file
Date
Mon, 13 Sep 2010 15:21:50 +0100
Martin,
Thank you for the article.
Unfortunately I cannot merge the two datasets, because I do not have a
merging variable in the original (names and addresses) dataset. The
postcode is not in a separate variable, and can appear in any of the
address lines. I therefore need to know the postcode before I can search
for and identify the postcode in the address.
Furthermore, I cannot think of a way to look through the postcodes from
the postcode file without reading in the file, and therefore clearing the
original dataset, which is not what I really want to do.
Many thanks,
Gillian
"Martin Weiss" <[email protected]>
Sent by: [email protected]
13/09/2010 15:06
Please respond to
[email protected]
To
<[email protected]>
cc
Subject
st: RE: Looping through entries in csv file
<>
Generally on looping, you want to see NJC`s
http://www.stata-journal.com/sjpdf.html?articlenum=pr0005
You might be better off -merge-ing the two files, with a judicious choice
of
the options for -merge- "being of the essence"...
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Montag, 13. September 2010 15:56
To: [email protected]
Subject: st: Looping through entries in csv file
Hello Statalist,
I have a bit of a data management problem, and I was hoping that you would
be able to help me.
I have a Stata data file containing about 60,000 names and addresses. The
addresses are held in 6 different variables, add1-add6, corresponding to
different lines of the address. The postcode can appear in any of the
address variables.
I also have a separate csv file that contains the postcode districts in
Great Britain (the section of postcode before the space, e.g. for the
postcode 'SK17 9JN' the postcode district is 'SK17'), and what county the
district belongs to (for example, the county for SK17 is "East Midlands").
There are about 2,800 postcode districts in total.
What I want to do is identify the county the individual lives in using the
postcode of their address. I thought that I might be able to do this as
follows:
For each line in the postcode csv file:
1. Identify if the postcode is present in any of the address variables
using -strpos(s1,s2)-
2. If present, set the county of the individual to be the county
corresponding to that postcode district from the csv file.
However, I am struggling to find a way to loop through the rows of the csv
file to enable me to search for each of the postcode districts in the
addresses.
I would greatly appreciate any help with this, as I am struggling to think
of a way to do it. Please let me know if anything needs clarifying.
Many thanks,
Gillian
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential information intended
for the addressee(s) only. If this message was sent to you in error,
you must not disseminate, copy or take any action in reliance on it and
we request that you notify the sender immediately by return email.
Opinions expressed in this message and any attachments are not
necessarily those held by the Health and Safety Laboratory or any person
connected with the organisation, save those by whom the opinions were
expressed.
Please note that any messages sent or received by the Health and Safety
Laboratory email system may be monitored and stored in an information
retrieval system.
------------------------------------------------------------------------
Think before you print - do you really need to print this email?
------------------------------------------------------------------------
------------------------------------------------------------------------
Scanned by MailMarshal - Marshal's comprehensive email content security
solution. Download a free evaluation of MailMarshal at www.marshal.com
------------------------------------------------------------------------
*
* 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/
*
* 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/
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential information intended
for the addressee(s) only. If this message was sent to you in error,
you must not disseminate, copy or take any action in reliance on it and
we request that you notify the sender immediately by return email.
Opinions expressed in this message and any attachments are not
necessarily those held by the Health and Safety Laboratory or any person
connected with the organisation, save those by whom the opinions were
expressed.
Please note that any messages sent or received by the Health and Safety
Laboratory email system may be monitored and stored in an information
retrieval system.
------------------------------------------------------------------------
Think before you print - do you really need to print this email?
------------------------------------------------------------------------
------------------------------------------------------------------------
Scanned by MailMarshal - Marshal's comprehensive email content security
solution. Download a free evaluation of MailMarshal at www.marshal.com
------------------------------------------------------------------------
*
* 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/