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

From |
Johannes Geyer <JGeyer@diw.de> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Rearranging Variables |

Date |
Mon, 4 Feb 2008 12:47:40 +0100 |

I think the problem ist that interview dates vary, so you collect information from a maximum of 23 months for each wave (Interview date January until December). You could reshape your data not only by person-year observations but by person-month observations per row. Use an index starting with 1 in January 1999, use the same index for your interview dates and as far as I know those unemployment spells are also indexed in a similar way in GSOEP. Use the person-months rows to generate your aggregated variable (unemployment months within the last 12 months before the interview date) with time-series operators e.g., and then reshape it back to person-year rows. Johannes ---------------------- Johannes Geyer Deutsches Institut für Wirtschaftsforschung (DIW Berlin) German Institute for Economic Research Department of Public Economics DIW Berlin Mohrenstraße 58 10117 Berlin Tel: +49-30-89789-258 Alekos Bibudis <alekos.bibudis@phil.tu-chemnitz.de> Gesendet von: owner-statalist@hsphsun2.harvard.edu 03/02/2008 19:48 Bitte antworten an statalist@hsphsun2.harvard.edu An statalist@hsphsun2.harvard.edu Kopie Thema Re: st: Rearranging Variables Hi again Im sorry, my initial post was not really clear. I will try to explain correctly what I am after. My Data (Paneldata / wide format): - individual Data on month of Interview from 2000 to 2006 (month00 - month06) coded 1 to 12 - unemployment status for each month in the years 1999 to 2005 (Jan99 to Dez05) coded 1/0 - ID of the interviewee. Target: 12 variables (month1 to month12) holding unemployment information of the 12 months before the interview (for the interviewmonths Jan00 to Jan06). for example: Interviewmonth = January 2000, the first variable (month1) should contain the data from Dec 1999, the second the value of Nov 1999 ... the last (month12) the value of Jan 1999 What I think would be the right way: reshaping variables into the long format, this way I will have the interview month in each wave as well as unemployment status each month like this: ID year month Jan Feb Mar ... Dez 1 1999 - 1 1 0 0 1 2000 3 1 1 0 0 1 2001 7 0 0 0 1 1 2003 9 1 1 1 0 ... code Idea for the first month before the inteview: generate Monat1 = Dez(year-1) if month == 1; replace Monat1 = Jan if month == 2; replace Monat1 = Feb if month == 3; replace Monat1 = Mar if month == 4; replace Monat1 = Apr if month == 5; replace Monat1 = Mai if month == 6; replace Monat1 = Jun if month == 7; replace Monat1 = Jul if month == 8; replace Monat1 = Aug if month == 9; replace Monat1 = Sep if month == 10; replace Monat1 = Okt if month == 11; replace Monat1 = Nov if month == 12; There are two problems with that code I don't know how to solve: 1. Assumed Data is sorted by ID and year, how do I tell Stata to use the value of a variable one column above the actual one (that is in the year before the interview was conducted)? In the example above, in 2000 January was the month of interview for respondent 1, the month before the interview is Dec 1999 which is not stored in the same colum as the interviewmonth-data (I tried to represent that in the code-idea with "Dez(year-1)" which I know is not correct). 2. In order to create variables for 12 months I'd have to type this code like twelve times with an increasing suffixvalue of the new generated variable (month1 to month12) and the month occupational status was conducted varying. How can this be shortened? I hope I made myself much clearer this time and that one of you might know the trick :-) Alekos >Alekos, >It would be helpful if you could explain why your commands do not >work. One problem with your code is that "if month`x' = 1" should be >"if month`x' == 1". > Friedrich > On Feb 1, 2008 3:49 PM, Alekos Bibudis <alekos.bibudis@phil.tu-chemnitz.de> wrote: > > Hi everyone. > > > > 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. > > > > -- > > ___________________________ > > Dipl.-Soz. Alekos Bibudis > > "Betrieb und Beschäftigung im Wandel" > > SFB 580, Projekt B2 > > Friedrich-Schiller-Universität Jena > > > > Phone: +49-(0)371-6957616 > > Website: http://www.sfb580.uni-jena.de * * 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/ * * 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/

**References**:**Re: st: Rearranging Variables***From:*Alekos Bibudis <alekos.bibudis@phil.tu-chemnitz.de>

- Prev by Date:
**st: Re: length of a string** - Next by Date:
**st: R: Correct formatting of survival data** - Previous by thread:
**Re: st: Rearranging Variables** - Next by thread:
**Re: st: Rearranging Variables** - Index(es):

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