Hi everyone,

I was wondering if I could get help to figure out the problem with one of my commands. I have been over it several times, and it would be great to get another opinion!

I have to calculate bid-ask spread of stocks of 194 companies (company name = ticker), using the first order serial covariance between the returns of the stocks. The returns are calculated using transaction prices, which is the variable close.

The command I am having problem with is:

forvalues i = 1/`N'{
quietly correlate return lreturn if ticker_new==`i', covariance
replace cov_returns = r(cov_12) if ticker_new==`i'
}

You can find the rest of the do-file below


Thank you for your time and help!
Sarika

Array