Statalist


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

st: RE: Rearranging Variables


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Rearranging Variables
Date   Sun, 3 Feb 2008 17:11:51 -0000

I don't want the GSOEP is, although that detail seems incidental. 

If I understand this correctly, your approach just compounds the problem
with the data structure. 

For most subsequent analyses with Stata, you would be much better off
with a long data structure, rather than this wide one, in the
terminology of 
-reshape-. Check out -reshape-, and then -tsset-. You will then find
that creation of variables like this is easier or indeed unnecessary. 

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

Alekos Bibudis

Using data from the GSOEP I`d like to transform some variables handling 
with information on occupational status.
There is a variable for each wave and month of the year holding 0/1 
coded information wether the person was unemployed at this point in time

or not (84 variables from Jan99 to Dez05).
I additionally have information on the month and year the interview was 
conducted. That is for each wave a variable coded 1 (Jan) to 12 (Dec) (7

variables from month00 to month06).

What I'd like to arrange is to generate twelve new variables holding the

information of unemployment status of the twelve months BEFORE the 
interview was conducted (Monat1 to Monat12) starting with Interviewmonth

Jan00 and ending with Jan06. 

The logic would be:
generate a new yariable and give it the value of the month before the 
interview
generate another new variable and give it the value of two months before

the interview
...
generate a last variable and give it the value of twelve months befor 
the interview

For 2006 there is no information on unemployment status, because it will

be gathered retrospectivively in the next wave.

Here's what I've tried, I know it doesn't work, but maybe it'll help to 
see what I'm after:

#d;
version 9.1;
local y = 1999;
foreach x in 00 01 02 03 04 05 06{;
gen Monat1 = Dez`y' if month`x' = 1;
local y = `y' + 1;
};

I'd appreciate every help I can get on this.

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