Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Convert yearly to monthly data


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Convert yearly to monthly data
Date   Fri, 31 Aug 2007 18:04:31 +0100

-reshape- is your friend. 

In fact, to -reshape- your data are wide, not long. 

Nick 
n.j.cox@durham.ac.uk 

Nikolaos Kanellopoulos
 
> I have a typical longitudinal data set, which gives me 
> information about the
> status of individuals for each month within a year. The data 
> are in a long
> format, thus every row represents a year. Variable pid 
> distinguishes the
> individuals and variable year shows the time dimension. Every month is
> represented by a variable (v1-v12). This is a binary variable 
> but it can
> also contain missing values.
> 
> My question is how I can convert my data from yearly panel to 
> monthly panel
> based on v1-v12.
> 
> To show what I mean, let's say that my original data look like that:
> 
> pid	year	v1	v2	v3	v4	v5	v6	
> v7	v8
> v9	v10	v11	v12	x
> 1	1	1	1	1	1	1	1	
> 1	1
> 1	1	1	1	.1369841
> 1	2	1	1	1	1	1	1	
> 1	1
> 1	1	1	1	.6432207
> 1	3	1	1	1	1	0	0	
> 0	1
> 1	1	1	1	.5578017
> 2	3	1	1	1	1	1
> 1	.0610638
> 2	4	1	1	0	0	0	0	
> 1	1
> 1	1	1	1	.5552388
> 
> I want to convert them so they will look like:
> 
> pid	v	year	x
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	1	.1369841
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	2	.6432207
> 1	1	3	.5578017
> 1	1	3	.5578017
> 1	1	3	.5578017
> 1	1	3	.5578017
> 1	0	3	.5578017
> 1	0	3	.5578017
> 1	0	3	.5578017
> 1	1	3	.5578017
> 1	1	3	.5578017
> 1	1	3	.5578017
> 1	1	3	.5578017
> 1	1	3	.5578017
> 2	1	3	.0610638
> 2	1	3	.0610638
> 2	1	3	.0610638
> 2	1	3	.0610638
> 2	1	3	.0610638
> 2		3	.0610638
> 2		3	.0610638
> 2		3	.0610638
> 2		3	.0610638
> 2		3	.0610638
> 2		3	.0610638
> 2	1	3	.0610638
> 2	1	4	.5552388
> 2	1	4	.5552388
> 2	0	4	.5552388
> 2	0	4	.5552388
> 2	0	4	.5552388
> 2	0	4	.5552388
> 2	1	4	.5552388
> 2	1	4	.5552388
> 2	1	4	.5552388
> 2	1	4	.5552388
> 2	1	4	.5552388
> 2	1	4	.5552388
> 			

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