Dear Stata Users,
I have a dataset in STATA as below:
I need to construct the dataset that will look like the one below, where “max_age” indicates the maximum number variable “age” with non-missing consecutive data that starts from t+1 after peak==1:
Thank you for your help.
I have a dataset in STATA as below:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str3 fic int year byte(age peak) "AA" 2011 . 1 "AA" 2012 1 0 "AA" 2013 2 0 "AA" 2014 . 0 "AA" 2015 . 0 "AA" 2016 . 0 "AA" 2017 . 1 "AA" 2018 1 0 "AA" 2019 2 0 "AA" 2020 3 0 "BB" 1988 4 0 "BB" 1989 . 1 "BB" 1990 1 0 "BB" 1991 2 0 "BB" 1992 3 0 "BB" 1993 0 0 "BB" 1994 5 0 end
I need to construct the dataset that will look like the one below, where “max_age” indicates the maximum number variable “age” with non-missing consecutive data that starts from t+1 after peak==1:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str3 fic int year byte(age peak) float max_age "AA" 2011 . 1 2 "AA" 2012 1 0 . "AA" 2013 2 0 . "AA" 2014 . 0 . "AA" 2015 . 0 . "AA" 2016 . 0 . "AA" 2017 . 1 4 "AA" 2018 1 0 . "AA" 2019 2 0 . "AA" 2020 3 0 . "BB" 1988 4 0 . "BB" 1989 . 1 3 "BB" 1990 1 0 . "BB" 1991 2 0 . "BB" 1992 3 0 . "BB" 1993 0 0 . "BB" 1994 5 0 . end
Comment