I can do all of this interactively, but need help writing loops.
(1) Suppose I have a variable, say Var1
How can I write a fundction that calculates the change between successive
observations of 10 elements of this variable? Ie. Assume the data is sorted
by date, decending. The first observation is (Var1[_n]
-Var1[_n+10])/Var[_n+10], the second observation is
(Var1[_n+2]-Var1[_n+11])/Var1[_n+11], and so on...Is this an instance where
I can use the -rolling- command? If so, how?
(2) Now suppose I want to do this same calculation across say, a hundred
variables Var1-Var100. How can I loop across the variables in an efficiant
manner?
(3) A more general type of loop: suppose I have 100 variables, and I want to
display the mean and std. Deviation of each varible.
Any help will be greatly appreciated. Please be specific regarding the
coding!