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
Foreach loop to populate missing observations of a variable from one year to multiple yearsI am working on several variables that i reshaped data from wide to long format and created a year v…
Regressions with Dummy VariablesArray Hi all, I am trying to replicate the following table. My code is as follows: foreach depende…
Propensity score matchingDear Stata colleges, I have a problem with the comand teffects overlap. I have run two propensity s…
Comparing sub-categories of a categorical variable across two groupsHello. I am trying to create descriptive statistics across two groups (treatment and control) for a …
How to do indirect estimation of two odds ratios?Hi Statalist members, I am planning to do a meta-analysis to find out the odds of having oral cance…
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