Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: reshape query


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: reshape query
Date   Tue, 4 Dec 2012 07:03:53 -0600

On Tue, Dec 4, 2012 at 6:30 AM, Tim Evans <[email protected]> wrote:
> Hi all,
>
> I'm using Stata 11.2, and am having a little trouble with -reshape-.
>
> I have a dataset with data as such:
>
> year    age     Males   age     mmx     mqx     mlx             mdx       mex           Females fmx     fqx     flx             fdx     fex
> 1982    0.00    Males   0.00    0.01    0.01    100000.00       1281.70  70.81  Females 0.01    0.01    100000.00       994. 76.80
>
> I want to set the data up so that I have:
>
> Year Sex        age mx  qx      lx              dx              ex
> 1982 Males      0   0.01        0.01    100000.00       1281.70         70.81
> 1982 Females0   0.01    0.01    100000.00       994.0           76.80
>

Note - you have two variables named age.

clear
input year    age  str5   Males        mmx     mqx     mlx
mdx       mex  str8 Females fmx     fqx     flx             fdx
fex
1982    0.00    "Males"      0.01    0.01    100000.00       1281.70
70.81  "Females" 0.01    0.01    100000.00       994. 76.80
end
rename (Males Females) (sexm sexf)
rename m* *m
rename f* *f
reshape long sex mx qx lx dx ex, i(age year) string
l

Scott
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index