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]

st: RE: rehape query?


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: rehape query?
Date   Mon, 23 Jul 2012 12:33:17 +0100

I see no identifier, so you need one. 

gen id = _n

Then you can make progress with 

reshape long m , i(id) string

But it seems that you have m* for males; presumably also f* for females. If so, it's probably something like 

reshape long m f, i(id) string

followed by another -reshape- stacking the m's and the f's. 

See also 

FAQ     . . . . . . . . . . . . . . . . . . . . . . . .  Problems with reshape
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        8/05    I am having problems with the reshape command. Can
                you give further guidance?
                http://www.stata.com/support/faqs/data/reshape3.html

on creating an identifier when needed and the long-long double -reshape-. 

Nick 
[email protected] 

Tim Evans

Hi, I'm using Stata 11.2.

I have a dataset in the following format:

year	dep_val	m0004		m0509		m1014
1981	Affluent	536212	595619	719034
1981	Average	278534	299131	364013
1981	Deprived	638771	651976	800071
1982	Affluent	544452	564154	700325
1982	Average	283399	283462	353927
1982	Deprived	652394	618789	776801
1983	Affluent	551374	542624	680392
1983	Average	287977	272890	343038
1983	Deprived	666933	597369	751282


I wish to reconfigure the dataset so that it looks more like this:

Year dep_val  sex	age_grp 	pop
1981 Affluent m	0004    	536212
1981 Affluent m	0509		595619
1981 Affluent m 	1014		719034
1981 Average  m	0004		278534
1981 Average  m	0509		299131
1981 Average  m 	1014		364013

I would group the data by year  - i.e. 1981, each age_grp in each dep_val.

Does anyone have a solution I could use, which is going to use some aspect of -reshape- I've got a little confused by it.	

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index