Hello statalist!
I have a dataset in long format which measure enrollment under a period of time. Even if you are enrolled more than 1 year, they are sometimes appearing under the same row (id 1) or separated in different rows (id 3)
id year start_date end_date days_between
1 2011 01/01/2011 01/03/2013
2 2007 01/06/2007 01/10/2007
3 2003 01/01/2003 31/12/2003
3 2003 01/01/2004 31/12/2004
I've figured out how to convert to date format and calculate days between. My question is how I can separate days between by years? Take id 1 as an example. The individual have start_date in 2011 and end_date in 2013. Calculate days between would give all days between 01/01/2011 and 01/03/2013, but I want days between 01/01/2011 - 31/12/2011, 01/01/2012 - 31/12/2012 and 01/01/2013 - 01/03/2013. Ideally, it would look something like this:
id start_date end_date days_between
1 01/01/2011 31/12/2011
1 01/01/2012 31/12/2012
1 01/01/2013 01/03/2013
Is this possible to achieve?
Best regards
Related Posts with Days between two dates, separated by year.
Dividing series of variables through loopingHi, I have variables Jan_13 to Mar_21, referring to months January 2013 to March 2021. I need to cre…
Suggestions for statistical tests to run on variables before OLS regression?Hi guys, Im a beginner user, i have a short project that i need some help on. I have an OLS regress…
l2.X variable as IV for X? Anderson Hsiao(1981). how to test for endogeneity panel (2sls)Hi, I'm a student and I'm trying to determine a model to use for my dataset. The goal is to estimate…
Validity and Robustness checks for Pooled/Repeated Cross-Sectional DataHi, I am trying to identify the impact of race on unemployment (due to COVID-19) from April to Decem…
Is my use of a t-test with this data appropriate?Hallo Apologies for not using dataex. I have tried and failed to install it (I used ssc install dat…
Subscribe to:
Post Comments (Atom)
0 Response to Days between two dates, separated by year.
Post a Comment