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.
How to draw graph with both axis labeled with different scaleMy code: twoway (scatter state year, sort by(province)) (scatter wagepre year, sort yaxis(2) by(pro…
Time Series HelpI'm modelling GDP on exports and imports over a given time period. Do you make sure the data is stat…
turn off dotted lines in marginsplot, recast(dot)Dear Statalist, Does anyone know how to get rid of the vertical dotted lines in the plot below? I t…
How to assess Granger causality and use the 'vec' command in Stata?I am interested in determining whether electricity consumption causes GDP or vice versa, following t…
2019 GERMAN USERS GROUP MEETING, Announcement and Program_________________________________ 2019 GERMAN USERS GROUP MEETING Announcement and Program _______…
Subscribe to:
Post Comments (Atom)
0 Response to Running a tabulation and putexcel loop when some tabulate outcomes have no observations.
Post a Comment