Hello Statalist; I have a dataset formatted long, with survey waves and corresponding date administered. How can I efficiently create a new variable that calculates the number of days between the date of Wave 12 and each previous date?
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(person_id survey_wave survey_date) 2 1 20784 2 2 20811 2 2 20809 2 2 20787 2 2 20810 2 2 20800 2 2 20802 2 2 20788 2 2 20812 2 2 20797 2 2 20793 2 2 20813 2 2 20792 2 2 20808 2 2 20798 2 2 20801 2 2 20806 2 2 20807 2 2 20789 2 2 20786 2 2 20805 2 2 20794 2 2 20790 2 2 20791 2 2 20785 2 2 20799 2 2 20795 2 2 20803 2 2 20804 2 2 20814 2 2 20796 2 3 20819 2 4 20980 2 5 20994 2 5 20988 2 5 20985 2 5 20992 2 5 20984 2 5 20982 2 5 20990 2 5 20991 2 5 20989 2 5 20993 2 5 20981 2 5 20987 2 5 20986 2 5 20983 2 7 21013 2 8 21069 2 12 21449 3 1 20784 3 2 20811 3 2 20813 3 2 20799 3 2 20802 3 2 20809 3 2 20785 3 2 20789 3 2 20810 3 2 20807 3 2 20795 3 2 20793 3 2 20794 3 2 20805 3 2 20800 3 2 20798 3 2 20790 3 2 20814 3 2 20812 3 2 20801 3 2 20792 3 2 20791 3 2 20787 3 2 20803 3 2 20797 3 2 20788 3 2 20806 3 2 20804 3 2 20786 3 3 20817 3 4 20979 3 5 20984 3 5 20987 3 5 20986 3 5 20985 3 5 20988 3 5 20981 3 5 20982 3 5 20989 3 5 20983 3 5 20993 3 5 20994 3 6 21132 3 7 21013 3 8 21069 3 9 21209 3 10 21226 3 10 21222 3 10 21220 3 12 21434 end format %td survey_date
Comment