Dear all

Please advise how I can replace "extr_date" ONLY for id's where "age2019" is less than 18 years old. This new date should be a date when someone turns 18 years old i.e. ("dob"+ 18 years).


----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long id int dob float extr_date byte age2019
304957 14783 21701 18
307524 14794 21701 18
307524 14794 21701 18
307704 14814 21701 18
308037 14854 21701 18
308742 14844 21701 18
308861 14845 21701 18
308861 14845 21701 18
308861 14845 21701 18
308861 14845 21701 18
309755 14828 21701 18
309755 14828 21701 18
309867 14860 21701 18
309867 14860 21701 18
310029 14791 21701 18
310029 14791 21701 18
310848 14899 21701 18
310849 14866 21701 18
311081 14785 21701 18
311081 14785 21701 18
311081 14785 21701 18
311084 15382 21701 17
311275 14841 21701 18
311275 14841 21701 18
312148 14827 21701 18
312880 14901 21701 18
313348 14840 21701 18
313954 14871 21701 18
313955 14871 21701 18
314186 14933 21701 18
314437 14889 21701 18
314786 14881 21701 18
314822 14873 21701 18
314976 14945 21701 18
314995 14892 21701 18
315076 14946 21701 18
315163 14767 21701 18
315203 14930 21701 18
315525 14868 21701 18
315540 14920 21701 18
315659 14951 21701 18
315768 14905 21701 18
315898 14841 21701 18
315999 14823 21701 18
315999 14823 21701 18
315999 14823 21701 18
316015 14861 21701 18
316015 14861 21701 18
316015 14861 21701 18
316015 14861 21701 18
316015 14861 21701 18
316036 14776 21701 18
316578 14945 21701 18
316579 14945 21701 18
316804 14839 21701 18
316921 14903 21701 18
316921 14903 21701 18
316932 14959 21701 18
316937 14934 21701 18
317043 14977 21701 18
317043 14977 21701 18
317043 14977 21701 18
317760 14911 21701 18
317792 14987 21701 18
318141 14994 21701 18
318248 14895 21701 18
318349 14978 21701 18
318349 14978 21701 18
318618 14970 21701 18
318618 14970 21701 18
318872 15006 21701 18
319024 14979 21701 18
319185 14991 21701 18
319367 15007 21701 18
319367 15007 21701 18
319459 15001 21701 18
319505 14953 21701 18
320077 14783 21701 18
320103 14770 21701 18
321235 14908 21701 18
321253 15040 21701 18
321280 14861 21701 18
321302 14912 21701 18
321350 14914 21701 18
321350 14914 21701 18
321589 15021 21701 18
321945 15042 21701 18
321945 15042 21701 18
322365 14936 21701 18
322607 14867 21701 18
322607 14867 21701 18
322607 14867 21701 18
322607 14867 21701 18
322607 14867 21701 18
322765 14982 21701 18
322765 14982 21701 18
322778 15065 21701 18
323158 15115 21701 18
323158 15115 21701 18
323341 15025 21701 18
end
format %td dob
format %td extr_date