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]

st: Tidying up a New and Old ID mapping dataset


From   Ada Ma <[email protected]>
To   [email protected]
Subject   st: Tidying up a New and Old ID mapping dataset
Date   Wed, 9 Mar 2011 16:23:36 +0000

Dear Statalist,

I have this dataset which has two series of number IDs.  Say it looks like this:

OriginalID    NewID
A                E
B                E
D                E
C                D


I need to map this information to existing data sets, so that all the
observations A, B, C, D, are mapped to become E.

As you can see it's rather straightforward for the first three
observations, but for the fourth observation, C is mapped to D.  I
need to correct this information so that when the NewID is found
amongst the OriginalID, it is updated to contain the correct NewID.

I need to write a few line of commands that would pick up the fourth
observation because it's NewID appears as the OriginalID in the third
observation, and replaces the fourth obs's NewID with the third obs's
NewID, so that the corrected dataset looks like this.

OriginalID    NewID
A                E
B                E
D                E
C                E


I can write a loop to compare the NewID against every OriginalID in
the data, but then it will take a few rounds of the looping to get the
whole thing tidied up, are there any better method?

Many thanks in advance!

Ada


-- 
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index