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]

Re: st: Merge question


From   William Buchanan <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Merge question
Date   Sat, 30 Mar 2013 13:23:01 -0700

Then there are probably some details that others would need to know to be helpful.  For example, if your other dataset consists of many id-year observations, how would you identify which value of your variables of interest should be coded as var1, var2, etc...?  

There is probably some way that you've managed to identify which values should become specific variables.  In that case, reshape the data with that additional information.

HTH,
Billy

Sent from my iPhone

On Mar 30, 2013, at 11:40, Rohit Sonika <[email protected]> wrote:

> I am afraid -reshape- wouldn't work if the using dataset has multiple observations per id-year.
> 
> Rohit
> 
> On 30 Mar 2013, at 18:12, Rohit Sonika <[email protected]> wrote:
> 
>> Dear Statalist,
>> 
>> I have a rather odd question concerning -merge-.
>> 
>> I am trying to do a -merge 1:m- using two datasets. I understand that when using the 1:m command, I am asking for duplicate matches to be added below other matches. However, is it possible to, instead of creating duplicate rows, add extra columns for vars in keepusing options?
>> 
>> For instance, if I am trying to match two datasets based on id and year while only keeping return and exdate from the using file, the merge command would look something like this:
>> 
>> merge 1:m id year using "XXXX", keepusing(return exdate)
>> 
>> Depending on the number of additional matches per id and year, is it possible to create extra variables like return1, return2, etc. and exdate1, exdate2, etc. rather than duplicate the entire observation? Hence, if for a given id and year there are 3 matches, it should create two additional return and exdate variables (return1, return2, exdate1 and exdate2) for the two additional matches (the first match being stored in return and exdate).
>> 
>> Thanks a lot for your help.
>> 
>> Best,
>> Rohit
> 
> 
> *
> *   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/

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index