Hi,
I want to create a daily report of survey submissions for each enumerator-supervisor team made on the previous day
In the report, I want disaggregated numbers for each enumerator reporting the status of calls (complete/refused/rescheduled) and the number under each status.
I am doing this by writing a loop and exporting results using - putexcel.
However, it is possible that an enumerator may not encounter a particular kind of status in the previous day.
gen yesterday = date("`c(current_date)'", "DMY") - 1
local usernames Paras Vedbati Sonia Kamlavati Sucheta
local ncol = 2 /* start the table in column B*/
foreach x of local usernames {
local col: word `ncol' of `c(ALPHA)'
putexcel `col'6 = ("`x'")
tabulate outcome if subdate == yesterday & supervisor_name == "Neha" & first_enum_name == "`x'" & phone_response_short=="Asked to call a different number" , matcell(freq)
putexcel `col'7 = matrix(freq)
tabulate outcome if subdate == yesterday & supervisor_name == "Neha" & first_enum_name == "`x'" & phone_response_short=="Complete", matcell(freq)
putexcel `col'8 = matrix(freq)
local ++ncol
}
Now under this loop , when Stata encounters an enumerator who may not have had encountered for instance the outcome phone_response_short=="Asked to call a different number"', then it throws an error as below:
no observations
freq not found
r(111);
How can I ensure that the loop continues, instances with no observations are ignored and the putexcel continues to run?
Would appreciate any help!
Thanks,
Rosa
Related Posts with Running a tabulation and putexcel loop when some tabulate outcomes have no observations.
results missing from correlation matrix?Hi guys I am not sure why STATA dropped some variables in the corr table:as attached the second pic…
How to run Nearest Neighbor Matching (nnmatch) on panel data?I am trying to run a Nearest Neighbor Matching in order to run a DID inference on it. Background: …
Analysis of stock market data - Excel or Stata?Hi, I have daily stock market data of 728 firms from 2000 to 2015 (about 4200 prices per stock). I …
Diff-in-diff with xtregHi everyone, I have some questions about the difference-in-differences (DID) model with fixed effec…
linking data according to dateHi I am fairly new to stata and I have some data that I am evaluating for patients receiving cancer …
Subscribe to:
Post Comments (Atom)
0 Response to Running a tabulation and putexcel loop when some tabulate outcomes have no observations.
Post a Comment