Statalist The Stata Listserver


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

Re: st: merging data unique identification problem


From   [email protected]
To   [email protected]
Subject   Re: st: merging data unique identification problem
Date   Tue, 31 Jan 2006 15:21:08 -0600

Try -reshape-

For example:


     +--------------------------------------------+
     | id   year   semester   grantt~e   awardamt |
     |--------------------------------------------|
  1. |  1   1990       Fall          1        500 |
  2. |  1   1990       Fall          0        200 |
     +--------------------------------------------+

. reshape wide award , i(id) j(gra)
(note: j = 0 1)

Data                               long   ->   wide
-----------------------------------------------------------------------
------
Number of obs.                        2   ->       1
Number of variables                   5   ->       5
j variable (2 values)         granttype   ->   (dropped)
xij variables:
                               awardamt   ->   awardamt0 awardamt1
-----------------------------------------------------------------------
------

. l, abb(32)

     +----------------------------------------------+
     | id   awardamt0   awardamt1   year   semester |
     |----------------------------------------------|
  1. |  1         200         500   1990       Fall |
     +----------------------------------------------+


Hope this helps,
Scott

----- Original Message -----
From: Jennifer Delaney <[email protected]>
> 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
> 


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