Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: Reshape and Changing Data


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: Reshape and Changing Data
Date   Sun, 21 Jun 2009 15:59:35 +0200

<> 

Try this:

*************
clear*

input  Year  str15 UN_Name Un_Code Sex Age15 Age20 Age25 Age80 str5(Reg6
Reg14)
2005  Albania   8    1  500    466      453  150 Eur  EurD
2006  Albania   8    1  550    500      498  160 Eur   EurD
2010  Albania   8    1  600    567      542  165 Eur  EurD
2005  Albania   8    2  400    395      350  140 Eur  EurD
2006  Albania   8    2  498    445      390  121 Eur  EurD
2010  Albania   8    2  534    500      486   133 Eur  EurD
2005  Andorra  20  1   500    450      423  100      Eur  EurC
2006  Andorra  20  1   534    480      420  110      Eur  EurC 
end

compress
list, noobs 

reshape long Age, /* 
 */ i( Un_Code Sex Year )/* 
 */  j( popage )

list, noobs /* 
 */ sepby(Un_C Sex)
*************



HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Gauri Khanna
Gesendet: Sonntag, 21. Juni 2009 15:41
An: Stata List
Betreff: st: Reshape and Changing Data


Dear Stata List, 
I would like to ?reshape- my data. 
Currently, my data is arranged such that the age-specific populations appear
as one observation for each year and sex: 
Year  UN_Name Un_Code Sex Age15 Age20 Age25??Age80  Reg6  Reg14
2005  Albania      8               1      500    466      453
150 Eur    EurD
2006  Albania      8               1      550    500      498
160 Eur     EurD
2010  Albania      8               1      600    567      542
165 Eur    EurD
2005  Albania      8               2      400    395      350
140 Eur    EurD
2006  Albania      8               2      498    445      390
121 Eur    EurD
2010  Albania      8               2      534    500      486
133 Eur    EurD
2005  Andorra     20             1       500    450      423             100
Eur     EurC
2006  Andorra     20             1       534    480      420             110
Eur     EurC
??
I would like to reshape it so that for every year and sex, each age in the
age-specific population is one observation and appears alongside the
population number it represents to be as:  
Year  UN_Name Un_Code Sex  Age        Pop  Reg6  Reg14
2005  Albania       8               1     Age15   500      Eur     EurD
2005  Albania       8               1     Age20   466      Eur     EurD
2005 Albania        8               1     Age25   453      Eur     EurD
2005 Albania        8               1     Age30   ??.
..
..
2005  Albania       8               2     Age15   400      Eur     EurD
2005  Albania       8               2     Age20   395      Eur     EurD
2005  Albania       8               2     Age25   350      Eur     EurD
2005  Albania       8               2     Age30   ??    Eur     EurD
..
I tried to reshape my data when I ran into several errors + there is the
added complication of creating a two new variables of « Age » and « Pop ». 
 
Will be grateful for your help. 
 
Regards, 
Gauri 
_________________________________________________________________
Windows Live?: Keep your life in sync. Check it out!
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_012009
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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