[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: A Question on Looping

From   Asgar Khademvatani <[email protected]>
To   [email protected]
Subject   st: A Question on Looping
Date   Tue, 18 Sep 2007 07:13:03 -0600

Dear Statalist

Actually, I have already generated four variable A, B, C, and D that each contains 43 observation, in Stata 8.2. I want to make 43 square matrix (2 by 2) using each of 43 observation based on each observation of these variables. Then, I want to calculate the real Eigenvalues of each matrix and list the 43 matrix and their Eigenvalues. I need to write a loop to do this job. Actually, I have already written the following loop using "foreach command" but I am getting the following error as follows;

foreach i = 1/43 {
2. matrix K[`i'] = (A[`i'], B[`i'] \ C[`i'],D[`i'])
3. matrix symeigen X[`i'] V[`i'] = K[`i']
4. matrix list K[`i'] V[`i']
5. }
invalid syntax

end of do-file

Also, alternativley, I have written another alternative do file by "while" loop but it is also subject to error as follows;

1.local i 1
2. while `i' < 43 {
3. matrix K[`i'] = (lpl_m[`i'], lpm_m[`i'] \ le_m[`i'],lk_m[`i'])
4. matrix symeigen X[`i'] V[`i'] = K[`i']
5. matrix list V[`i']
6. local i = `i' + 1
7. }
too many ')' or ']'

end of do-file

Could you help me out on this matter and say what is wrong with any of these alternative loops?

Asgar Khademvatani
* For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index