Dear ,
I want to transform my dataset into panel dataset.
Currently my dataset looks like this (first 5 lines)
id start3 end3
1 12jul1983 01jan1985
2 01jan1983 31dec2013
3 01jan1985 31dec2013
4 01jan1989 01jan1999
I want it to transform to:
id start3. end3 year
1 12jul1977 01jan1985 1983
1 12jul1977 01jan1985 1984
1 12jul1977 01jan1985 1985
2 01jan1983 31dec2013 1983
2 01jan1983 31dec2013 1984
2 01jan1983 31dec2013 1985
....
2 01jan1983 31dec2013 2013
and so on with a new variable year (or equivalent time variable that adds up for each year an item is still being observed)
I have tried several ways using 'expand' in combination with 'bysort', _n commands, but I can't reach the desired result.
Can someone please advise me on this?
best wishes
Kutsal Yesilkagit
Related Posts with expanding single observation into panel data with observations for each year an item exists
cox proportional hazard model with log-transformed variablesHi, I ran a cox proportional hazard model to predict cumulative baseline hazard and xbeta. My code …
Using Matrix commandDear Users, I have two freq tables as follows: Table 1 Code: pml | Freq. Per…
Question about recoding a variable, having issues with deleting some unwanted values.Hello everybody. I am a stata beginner, trying to do some descriptive analysis on a survey data. My…
Matching options using psmatch2Hi, I am performing propensity score matching using the "psmatch2" command (and, in particular, usi…
Query about r(5); errorI am following certain accounting models to estimate measures of financial reporting quality. I have…
Subscribe to:
Post Comments (Atom)
0 Response to expanding single observation into panel data with observations for each year an item exists
Post a Comment