Hi team,
I have a question regarding counting how many calls within my data are within a time period (say, 3months). I have the dates of calls stored correctly in datecall, but what I want to do is count, for any datecall, how many datecalls are within 90 days of it. I have my code below. You can see that I put datecall* which does not work--is there another way to signal this to stata? Thanks!
I have a question regarding counting how many calls within my data are within a time period (say, 3months). I have the dates of calls stored correctly in datecall, but what I want to do is count, for any datecall, how many datecalls are within 90 days of it. I have my code below. You can see that I put datecall* which does not work--is there another way to signal this to stata? Thanks!
Code:
gen numref_3m=0
gen numref_12m=0
foreach x of numlist 1/53 {
replace numref_3m = numref_3m+1 if datecall`x'<= datecall* & datecall`x' - datecall* < abs(90) & datecall`x'~=.
replace numref_12m = numref_12m+1 if datecall`x'<= datecall* & datecall`x' - datecall* < abs(365) & datecall`x'~=.
}

Comment