Hi all;
I am trying to download trade data via the UN Comtrade's API with the following loop:
(example)
where the numbers in the macro are country codes.
The problem is that sometimes within the loop I get the error message: " web error 409could not open url r(603);" which seems to pop up very randomly.
I can suppress the error message with "capture", but I would also like to know which files were not downloaded properly. Is it possible to track at which point in the loop the error occurred or write something like "If 'error message appears' then do xy"?
Thanks!
I am trying to download trade data via the UN Comtrade's API with the following loop:
(example)
Code:
global reporter "36 40 56" foreach rep in $reporter { import delimited "https://comtrade.un.org/api/get?r=`rep'&freq=a&ps=2012&p=76&px=h4&rg=2&cc=ag6&fmt=csv" save "comtrade_`rep'_76_2012.dta" clear }
The problem is that sometimes within the loop I get the error message: " web error 409could not open url r(603);" which seems to pop up very randomly.
I can suppress the error message with "capture", but I would also like to know which files were not downloaded properly. Is it possible to track at which point in the loop the error occurred or write something like "If 'error message appears' then do xy"?
Thanks!