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

st: RE: data manipulation


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: data manipulation
Date   Tue, 15 Jun 2004 23:03:48 +0100

Try 

egen series = rmin(series1 series2 series3) 
gen which = 1 * !mi(series1) + 2 * !mi(series2) + 3 * !mi(series3) 
drop series? 
reshape wide series , i(country year) j(which) 

Nick 
n.j.cox@durham.ac.uk 

jdubas@nd.edu

> I have what may be a basic question.  I have data like this:
> country year series1 series2 series3
> 1          1      1000     .         .
> 1          2      1035     .         .
> 1         1        .        50        .
> 1          2       .         53       .
> 1         1        .          .        7 
> 1         2        .          .         8.5
> 2 etc
> 
> 
> Is there anyway I can basically collapse these so that:
> country  year  series1   series2  series3
> 1           1      1000       50        7
> 1           2      1035       53        8.5
> 
> for a number of countries?

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index