Dear Stata experts,

I am really stuck. In my data set, I have variables for the participant's ID number (ID_number), plus baseline HbA1c values from an original study that collected data from Feb 06, 2009 to March 12, 2010 (baseline_HbA1c), plus the date that the HbA1c value was collected (date_of_HbA1c_test), plus the follow up HbA1c values (registry_HbA1c) that came from national registries for children and adolescents with type 1 diabetes. My registry_HbA1c values basically span from a date in 2008 to a date in 2020.

My goal is to only only keep the registry_HbA1c value if the date_of_HbA1c_test was over 1 year AFTER the baseline HbA1c_value was collected for each individual study participant ID_number. Again, the study participants had their baseline_HbA1c test done between Feb 06, 2009 to March 12, 2010. The registry_HbA1c values span from 2008 to 2020. How do I write these commands in Stata so that I only keep the registry_HbA1c values if the test was done 1 year AFTER the participant's baseline HbA1c was done?

* Example generated by -dataex-.
clear
input str 10 ID_number int baseline_HbA1c long date_of_baseline_HbA1c registry_HbA1c date_of_registry_HbA1c
"0000000000" 0000000000 60 mmol/mol 06feb2009 69 mmol/mol 07aug2009 (so do NOT want to keep this follow up value)
70 mmol/mol. 05jun2010 (so want to keep this follow up value)
73 mmol/mol. 01dec2015 (so want to keep this follow up value)
78 mmol/mol. 21nov2020 (so want to keep this follow up value)
"1111111111" 1111111111. 65 mmol/mol 10jul2009 72 mmol/mol. 18dec2009 (so do NOT want to keep this follow up value)
69 mmol/mol. 07jun2011 (so want to keep this follow up value)
72 mmol/mol. 28sep2017 (so want to keep this follow up value)
74 mmol/mol. 18dec2020 (so want to keep this follow up value)
68 mmol/mol. 20jun2010 (so do NOT want to keep this follow up value)

Thank you in advance for helping me to figure out how to keep registry_HbA1c values that are > 1 year after the baseline_HbA1c value

Kevin P. Marks

P.S. I used the -dataex- function in Stata but I did not copy and past the information... because I am using data from very secure national registries.