[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Updating master dataset with a transation dataset
I am relatively new to Stata, although I have programming experience in SAS
This is what I would like to do, but I cannot figure out how to do it in
1. My master dataset has hundreds of variables, two of which, var1 and
combine to use as a unique identifier of each record.
2. My second dataset, the transaction dataset, has 4 variables: two of
are the same two as in the master dataset, var1 and var2. They are
identifiers on this dataset.
a. The third variable in the transaction dataset, (var3), contains
of a variable in the master dataset which is to be updated. This
name is different from record to record on the transaction
b. The fourth variable, var4, contains the data that is to update
the master dataset.
Ex: I would match record from transaction dataset with master dataset record
on var1 and var2.
Then I would look at the contents of the var3 on the transaction dataset
would tell me the name of the variable that needed to updated on the master
on the transaction dataset would tell me what the contents of this updated
variable is to be.
It is possible to have several records in the transaction dataset all with
the same unique
identifier, instructing the system to update different variables on the same
record of the
Now I know that I can just create a series of replace varname with the
contents of var4
statements and copy and paste this data into a do-file, and run it that
But that is not very efficient, and I need to do this over and over again,
there is a way I could read the transaction dataset, then retrieve the
record from the master dataset, update the specified variable with it's
from var4, that would be better.
Is there anyway I can do this in Stata?
Thank you so much for your help.
Woodrow Wilson School
* For searches and help try: