Thank you Scott; I tried your commands with a sample of my data and with the entire data set and it worked.
I now have two ways of doing the same thing (yours and Martin's).
Many thanks,
Gauri
----------------------------------------
> Date: Sun, 21 Jun 2009 09:01:53 -0500
> Subject: Re: st: Reshape and Changing Data
> From: [email protected]
> To: [email protected]
>
> clear
> input year str8 un_name un_code sex age15 age20 age25 age80 str3 reg6
> str4 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
>
> gen id = _n
> renpfix age pop
> reshape long pop, i(id) j(age)
> l in 1/5
>
> Scott
>
>
> On Sun, Jun 21, 2009 at 8:41 AM, Gauri Khanna wrote:
>>
>> 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
>
> *
> * 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/
_________________________________________________________________
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/