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: Generating duplicate variables when merging by varname
From
Ludovico Zaraga <[email protected]>
To
statalist <[email protected]>
Subject
st: Generating duplicate variables when merging by varname
Date
Tue, 25 Feb 2014 10:26:47 -0600
Hello,
I have one dataset (the master dataset) with a list of countries,
product names and years. I then have another dataset with price
indices over all countries in a given year. The latter dataset does
not contain countries since it contains an index summarizing all
country information. Suppose I have N countries.
I would like to merge these two datasets in the following way. For
each product (in a given year) in the master dataset, I want to create
N variables (one for each country), all of which contain the price
index for that product (in a given year). These variables would have
the price index from the second dataset in correspondence to only one
country-product pair (for all the years in the dataset), and missing
values in correspondece to all other countries and products.
Is there a simple way to do this with a merge command, specifying some
"by" option? Or would I have to do this using foreach loops?
Thanks,
Ludovico
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/