Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: merging data unique identification problem


From   Rafal Raciborski <[email protected]>
To   [email protected]
Subject   Re: st: merging data unique identification problem
Date   Tue, 31 Jan 2006 16:23:00 -0500

. list

    +--------------------------------------+
    | id   year   semester   type   amount |
    |--------------------------------------|
 1. |  1   1990       Fall      1      500 |
 2. |  1   1990       Fall      0      200 |
 3. |  2   1990       Fall      0      200 |
 4. |  3   1990       Fall      0      300 |
 5. |  3   1990       Fall      1      750 |
    |--------------------------------------|
 6. |  3   1990       Fall      2      600 |
    +--------------------------------------+


. reshape wide amount, i(id) j(type)

<snip>

. list

    +----------------------------------------------------+
    | id   amount0   amount1   amount2   year   semester |
    |----------------------------------------------------|
 1. |  1       200       500         .   1990       Fall |
 2. |  2       200         .         .   1990       Fall |
 3. |  3       300       750       600   1990       Fall |
    +----------------------------------------------------+

since i suppose you have various years (not just 1990), you will have to use

. reshape wide amount, i(id year) j(type)

rafal



Quoting Jennifer Delaney <[email protected]>:

I have two datasets that I am trying to merge.  One dataset (A) is uniquely
identified by three variables (ID YEAR SEMESTER).  The other dataset is
uniquely identified by four variables (ID YEAR SEMESTER GRANTTPYE).  In the
second dataset (B) students can get more than one GRANTTYPE in a given
semester so it is important to keep this factor.

What I've been trying to do is to collapse the second dataset (B) so that it
is identified by only three variables then I can merge it with dataset A.

I think it's clearest if I can illustrate with a simple example...

Current form of dataset B:

ID  YEAR  SEMESTER  GRANTTYPE AWARDAMT
1   1990   Fall         1        500
1   1990   Fall         0        200


Form that I am attempting to convert dataset B into:

ID  YEAR  SEMESTER  GRANTTYPE1awardamt  GRANTTYPE2awardamt
1   1990   Fall          500                200


The only form that I have been able to achieve so far:
ID  YEAR  SEMESTER  GRANTTYPE1awardamt  GRANTTYPE2awardamt
1   1990   Fall          500                .
1   1990   Fall          .                  200


How do I "squish" the data so that I end up with one entry per kid per year
per term?

Thanks,

Jennifer

--
Jennifer Delaney
PhD candidate in Higher Education
Stanford University
[email protected]
*
*   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/



================
Rafal Raciborski
Graduate student
Department of Political Science
Emory University
301 Tarbutton Hall
1555 Dickey Drive Atlanta, GA 30322
404-378-9826 (home)
[email protected]
http://www.roofoos.net/


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