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.
Replace commandHello am new to stata, the task that am trying to achieve is to replace a numeric value with a strin…
Grouping of countries by continentI have deforestation data for 265 countries and want to analyse them separately by continent. I usua…
Panel data regression using dummiesHi everyone! I am attempting to create a panel data regression with lnwages as the dependent and ge…
Any way to override SSL error when importing?Hi All, I've been using a set of programs to scrape the USNO astronomical data for the past two yea…
Comparing multiple string variables for similarityDear all, I am trying to compare a string variable with several others for similarity: The goal is…
Subscribe to:
Post Comments (Atom)
0 Response to Running a tabulation and putexcel loop when some tabulate outcomes have no observations.
Post a Comment