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
starting values in mixedlogitDear All, I am analyzing a DCE to estimate WTP values for environmental protection and I am trying d…
Ttest or ranksum approach for panel dataHi there, I was hoping you could help. I would like to compare the means between 2 samples for pane…
building a categorial variable based on confidence intervallsDear all, I try to part a continous variable in categories using the 50% CI. Literture ref: "The a…
How to generate a variable with with fixed correlations to an existing variable which already has a uniform distributionHi, I have generate a variable which I have called X, it has a uniform distribution like this: gen x…
building a categorial variable based on confidence intervallsDear all, I try to part a continous variable in categories using the 50% CI for age groups. Litert…
Subscribe to:
Post Comments (Atom)
0 Response to Loading Data from ODBC Data source in a loop
Post a Comment