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: RE: Tidying up a New and Old ID mapping dataset
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: Tidying up a New and Old ID mapping dataset
Date
Wed, 9 Mar 2011 17:01:34 +0000
I don't know whether I understand this. The issue appears to be that according to one rule C should be mapped to D and according to another rule D should be mapped to E and that trumps the first rule. And presumably there are other examples this kind. And the example is not to be taken literally, but is schematic.
If that is so, all I can suggest is that the trumping rule is applied last, so that this sounds like -replace- followed by another. I don't know why a loop is thought necessary if there are most two steps.
Nick
[email protected]
Ada Ma
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?
*
* 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/