Hi all,
I'm sure this question has been answered before but I can't find it in search. I'm cleaning a series of dates that are numbered consecutively (int1datesurg, int2datesurg, int3datesurg). These should be always be consecutive (i.e. date2 should always come after date1). I want to create a loop that returns the ID of the observation and the first date if this is not true.
I think this is happening because I have over 100 variables that start with "int#"? I know Stata can't begin variable names with numbers and I want to keep the variables named in this convention for data management . Is there a way around this? Do I need to embed a foreach loop to get Stata to recognize "int`i'datesurg" as a variable name?
I'm sure this question has been answered before but I can't find it in search. I'm cleaning a series of dates that are numbered consecutively (int1datesurg, int2datesurg, int3datesurg). These should be always be consecutive (i.e. date2 should always come after date1). I want to create a loop that returns the ID of the observation and the first date if this is not true.
Code:
unab varlist : int* . forvalues i=1/25{ 2. list id int`i'datesurg if int`i'datesurg > int[`i'+1]datesurg 3. } int not found r(111);
Comment