Hi!
I'm new to Stata and working with longitudinal data for the first time - so maybe I am missing something.
I have data from participants from up to 6 waves on their depression status (dep). With this data I classified them further as new depression cases (dep_inc) or persistent depression cases (dep_per) in the susequent waves (if data on two subsequent waves was available).
My primary goal is to get one table that gives me the raw frequency, and weighted proportion/prevalence including CI by waves.
My secondary goal is to get this for all variables of interest in the same table. But they need different weighting. For dep I have cross-sectional weights and for dep_inc and dep_per I use longitudinal weights. Further, data from the last two variables is only available for waves 2 to 6 as in the first wave no incidence or persistence could be assessed.
I am unable to provide you with my data or parts of my data. Therefore I'm providing the closest data I could find online.
Is there a way to include all tables in the same table?
I'm using Stata 19.
Best,
Markus
I'm new to Stata and working with longitudinal data for the first time - so maybe I am missing something.
I have data from participants from up to 6 waves on their depression status (dep). With this data I classified them further as new depression cases (dep_inc) or persistent depression cases (dep_per) in the susequent waves (if data on two subsequent waves was available).
My primary goal is to get one table that gives me the raw frequency, and weighted proportion/prevalence including CI by waves.
My secondary goal is to get this for all variables of interest in the same table. But they need different weighting. For dep I have cross-sectional weights and for dep_inc and dep_per I use longitudinal weights. Further, data from the last two variables is only available for waves 2 to 6 as in the first wave no incidence or persistence could be assessed.
I am unable to provide you with my data or parts of my data. Therefore I'm providing the closest data I could find online.
Code:
// available dataset use https://www.stata-press.com/data/r19/nlswork.dta // add weighting variable (imagine cross-sectiona) set seed 18 gen double sampw = runiformint(10,50) + runiform() // add second weighting variable (imagine longitudinal) gen double sampw2 = runiformint(10,50) + runiform() svyset [pw=sampw2] // table for raw frequency and weighted proportion dtable i.c_city [pweight=sampw], by (year) // table for weighted proportion including confidence interval proportion i.c_city [pweight=sampw], over(year) level(95) // equivalent tables using the second weight dtable i.nev_mar i.msp [pweight=sampw2], by (year) proportion i.nev_mar i.msp [pweight=sampw2], over(year) level(95)
I'm using Stata 19.
Best,
Markus
Comment