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.
Remove blank space at the end of a graphHi Statalist! I am trying to get a plot of multiple time-series in one graph but I keep getting thi…
What distribution does it look like?Hello, I am doing multilevel data analysis using meglm command. . meglm y x, offset(t) || id:, fam…
How to generate the highest education Level at wave X, given the data from all previous survey waves?Dear All, I am working with longitudial survey and my dataset contains a data from the 7th Survey w…
How to count observation number (and percentage) based on var1 by var2?Hi,all, Description of my data set: Var 1 is education, with values indicate levels of education. V…
Converting a start and end date (a timeframe) into several annual time dummiesHi, I have observations with a start date and an end date (e.g. 04/31/1997 and 02/19/2002) and I wan…
Subscribe to:
Post Comments (Atom)
0 Response to Running a tabulation and putexcel loop when some tabulate outcomes have no observations.
Post a Comment