Hi Astounding,
This actual program
data XXX
....
....
....
"My program here"
....
...
...
run;
It will generate a new dataset with each asset having its own variance value. It will read in all the observations for AAPL excluding the last two observations and compute the variance. For this example, there are 5 observations for AAPL. Only the first 3 are used to compute the variance and the last two observations are used as filtering. The filter works like if the last two observations do not exist, variance for APPL will be deleted.
If it is difficult,
maybe you can teach me how to write a loop for the lagN?
Example:
I want to compute variance for 4 observations:
VarP = std(price, lag(price), lag2(price), lag3(price));
The algorithm is something like
{
N= 4;
xString = "price";
for i = 2: N
xString = concatenate( xString, ",", lag"i"(price));
end
VarP = std(xString);
}
Many thanks
... View more