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
Dropping observations after the first time the treatment turns offHello, I need some help finding a solution to the following problem: I want to drop all the observat…
Panel Data Logged Differences Help!!Hello thank you!! I'm doing a research project on whether or not individual CEO campaign contributio…
EFA-Factor AnalysisHello, I have survey data where five main factors and each factor has a set of questions. As we kno…
Gen match =_n1 replace match = _id if match ==. How can you have missing value ??Richard Hofler can you help? As I believe you were the author of this code re post 5 on here https:/…
ivreg2-weak instrument robust inferenceDear All, I was a bit confused about the validity of estimates after ivreg2. If the Kleibergen-Paap…
Subscribe to:
Post Comments (Atom)
0 Response to Loading Data from ODBC Data source in a loop
Post a Comment