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

From |
Myriam Nourry <myriam_nourry@yahoo.fr> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Pair-variables and creating a new dataset |

Date |
Sun, 19 Aug 2007 17:34:09 +0200 (CEST) |

Hello Statalist, I am a new user of Stata and I am wondering if I can do what I think whith Stata. I have a panel dataset with 74 countries between 1960-1990 and a variable (sulfur dioxid emissions per capita, say x). My dataset looks like : year countrycode x 1960 1 . . . . . . . 1990 . . 1960 74 . . . . . . . 1990 . . I want to analyse in terms of stationarity all the pairs (difference of emissions between country i and j): xi-xj (in fact 2701 pairs). With the following program, I succeed to compute all the pairs: sort year by year: gen freq=_N expand freq sort year countrycode by year countrycode: gen num=_n by year: gen pair_id=countrycode[freq*num] by year: gen x2=x[freq*num] drop if countrycode== pair_id drop if countrycode>pair_id by year: gen dist=x-x2 sort countrycode pair_id year But, I obtain a unique variable named dist. My dataset now looks like : year countrycode x pair_id dist 1960 1 . 2 x1-x2 . . . . . . . . 1990 . . 1960 1 . 3 x1-x3 . . . . . . . 1990 . . I want to test unit root (use of dickey-fuller test) on all the 2701 pairs. I don't know if it is possible to do this with the variable dist or if i have to obtain 2701 variables (each corresponding to a pair) and then use the syntax "foreach". So, I need your help ! I try to compute all the pair-variables with the following program: forvalues i=1/74 { forvalues j=2/74 { if (`i'~=`j' & `i'<`j') { gen paire`i'`j'=dist if countrycode==`i' & pair_id==`j' } } } but I obtain a variable paireij with 83731 observations, with only 31 non missing observations. I would like to take into account only the non-missing observations and obtain the following dataset : year pair12 pair13 . . pair7374 1960 x1-x2 x1-x3 x73- x74 . . . . . . . 1990 . . . Is it possible to do this with Stata and must I create this dataset on Excel and then input it on Stata ? Thank you very much for all idea you give me. Best Regards. Myriam Nourry _____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail * * 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/

**Follow-Ups**:**st: RE: Pair-variables and creating a new dataset***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**RE: st: Does a do file know its own name?** - Next by Date:
**RE: st: Does a do file know its own name?** - Previous by thread:
**st: Projection model - future performance** - Next by thread:
**st: RE: Pair-variables and creating a new dataset** - Index(es):

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