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

st: RE: Panel data manipulation question


From   "Paul Seed" <P.T.Seed@qmul.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Panel data manipulation question
Date   Wed, 17 Jul 2002 11:40:02 +0100

Taggert J Brooks' problem <brooks.tagg@uwlax.edu>
can be approached in a different way that gets round 
the missing data / incomplete panel issue.

> I have a panel data set on individual 
> countries and I
> want to create a new variable.  The variable is going to be 
> the ratio of a
> variable I already have in my dataset, we'll call it P.  I 
> want to create a
> variable we'll call X where x=p/p(i==72).  That is to say I 
> want to deflate
> all the values of p, by the value of p for country 72, for 
> the corresponding
> year.  

Assume the data is saved in myfile.dat.

use country year p using myfile if country == 72, clear
drop country
rename p p72
mmerge year using myfile , type(1:n)
gen x = p/p72

x will be missing only if p72 == 0, p ==. or p72 == .

************************
Paul Seed
p.t.seed@qmul.ac.uk
Medical Statistician
Wolfson Institute of Preventive Medicine 
Charterhouse Square
London EC1M  6BQ
(020) (+44) 7882 6298
fax 7882 6270
*
*   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