Dear Stata Forum,
I have encountered this problem yesterday and I could not figure out how to do it. I have to import a bunch of files from an online platform and save them in a folder. Basically, I have 1 file for each trading day. I tried looping with a local over dates, but it does not work (it works if I put the date myself in the code, but that is not feasible for more than 300 files). I tried something like this:
local dates 131218 311218
foreach x in local dates {
odbc load underlying_basket_isin="underlying_basket_isin" underlying_basket_aii="underlying_basket_aii" underlying_index_name="underlying_index_name" ///
notional_currency1="notional_currency1" trade_id="trade_id" execution_venue="execution_venue" compressed="compressed" price_notation="price_notation" ///
price_rate_eur="price_rate_eur" price_rate="price_rate" notional="notional" notional_eur="notional_eur" quantity_type="quantity_type" quantity="quantity" ///
up_front_payment="up_front_payment" execution_timestamp="execution_timestamp" effective_date="effective_date" maturity_date="maturity_date" ///
termination_date="termination_date" settlement_date="settlement_date" ccp_id_type="ccp_id_type" ccp_id="ccp_id" ///
clearing_timestamp="clearing_timestamp" intragroup="intragroup" underlying_maturity_date="underlying_maturity_date " ///
payment_freq_dq="payment_freq_dq" reference_period="reference_period", table(lab_prj_'x`_Positions) dsn("DISC DP Impala 64bit") clear noquote
cd "chosen directory"
save `x'_pos.dta,replace
}
but this does not work because Stata fails to recognize the x in the loop. Any sort of help is welcome! Thank you very much.
Filippo
Related Posts with Loading Data from ODBC Data source in a loop
Panel data + quantile regressionHello everyone, for an important seminar at my University I am running a gravity model of trade (Ja…
Pseudo R-squareds for melogitHi, Are there any packages to estimate (several) pseudo R-squareds after melogit? - I have noted t…
ppml vs ml with robust covariance estimationdeal all, i hope to use gravity model- I wonder what is difference between ppml and ml with robust c…
two part model vs heckmandear all do you guys know what is difference btw two part model and heckman model? thank you all! …
Renaming variables with modified versions of label namesHello I have data that is set out with a first row being numbers that I would like as variable name…
Subscribe to:
Post Comments (Atom)
0 Response to Loading Data from ODBC Data source in a loop
Post a Comment