Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: changing the structure of a data set


From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: changing the structure of a data set
Date   Tue, 9 Aug 2005 14:07:09 +0200

Barbara Hofmann,

You want to restructure a dataset in wide format to long format. It goes
like this, using -reshape-:

----------------------------------
clear
input var1 v1991 v1992 v1993
15   	8.58	8.76	9.53
16	1.01	.91	.9
17	.89	.75	.72
18	.39	.3	.3
19	.28	.23	.16
20	.52	.5	.6
21	.65	.56	.58
22	.89	1.07	.9
end

reshape long v , i(var1) j(year)
sort year var1
list
------------------------------------

Hope this helps
Svend

__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: sj@soci.au.dk
__________________________________________ 

*
*   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/



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