Dear Statalist users,
I have a panel dataset of students who participate in various activities as part of a university outreach programme. The timing that each activity takes place is reported in the following format: YYYY-MM-DD.
The students are also asked to report their intentions to apply at university at the beginning of each academic year. I want to look at the impact of activity participation on changes in students' intentions, considering the activities that happened between the first and last time each student reported their intentions.
To do this I created a variable which identifies the year each student reported their intentions for the first time (first_time) and another variable identifying the year they reported for the last time (last_time).
To identify activities that happened before a specific date I could use the following code:
What I would like to ask your help for is, if possible, to write a loop that would use the years in "first_time" and "last_time" and identify the activities that happened in the period in between.
For example, consider a student whose first_time=2017 and last_time=2020, I want to select the activities that happened between 01sep2017 and 01sep2020.
I hope that my explanation is clear and I honestly apologise if it's not. Any help would be beyond appreciated, thank you!
I have a panel dataset of students who participate in various activities as part of a university outreach programme. The timing that each activity takes place is reported in the following format: YYYY-MM-DD.
The students are also asked to report their intentions to apply at university at the beginning of each academic year. I want to look at the impact of activity participation on changes in students' intentions, considering the activities that happened between the first and last time each student reported their intentions.
To do this I created a variable which identifies the year each student reported their intentions for the first time (first_time) and another variable identifying the year they reported for the last time (last_time).
To identify activities that happened before a specific date I could use the following code:
Code:
g ddate = daily(startdate, "YMD") format %td ddate g before = cond(ddate < td(01sep2021), 1, 0) if !missing(ddate)
For example, consider a student whose first_time=2017 and last_time=2020, I want to select the activities that happened between 01sep2017 and 01sep2020.
I hope that my explanation is clear and I honestly apologise if it's not. Any help would be beyond appreciated, thank you!
Comment