I have the following code:
local date "September"
global dir `c(pwd)'
global files "A B C"
foreach x of global files {
import excel "${path}`x'_`date'.xlsx", sheet("1") cellrange(A3:O21) clear
generate Store="`x'"
save `x', replace
}
The problem is that not all my files have the date September. Some have August or May.
How can I incorporate a solution for this in the above script?
The idea is that if September is not found, the code would still run. However, instead of September it would go for August and if that fails, then May.