Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: RE: merge or alternative


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: RE: merge or alternative
Date   Sat, 31 May 2003 12:46:46 -0400

If Teacher is unique in Dataset 2, then this is a simple merge (of variety
many-to-one):

use dataset1
sort teacher
merge teacher using dataset2


Michael Blasnik
[email protected]

----- Original Message ----- 
From: "adonlan" <[email protected]>
To: <[email protected]>
Sent: Friday, May 30, 2003 6:31 PM
Subject: st: RE: merge or alternative


> I want to combine datasets 1 (student ID and teacher name) and 2 (type of
> class) to create dataset 3, as shown below.   I don't think it is a simple
> merge.
>
>    Part of the complication may arise from the fact that datasets 1 and 2
have
> different numbers of cases.  I am inclined to suspect I should use
"generate"
> in a one-by-one way to insert the data needed from dataset 2, rather than
> merge.
>
> *************
> DATASET 1
> Student           Teacher
>
> Student1 Teacher1
> Student2 Teacher2
> Student3 Teacher1
> Student4 Teacher2
> Student5 Teacher1
>
> DATASET 2
> Teacher        Class Type
>
> Teacher1 a
> Teacher2 b
>
> DATASET 3
> Student         Teacher         Class Type
> Student1 Teacher1 a
> Student2 Teacher2 b
> Student3 Teacher1 a
> Student4 Teacher2 b
> Student5 Teacher1 a
>


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index