You defined the program, but you didn't actually
run it.
Try
. test
Here is a suggestion for version 2:
prog define test
version 7
matrix A = J(3,3,1)
matrix list A
forval i = 1/4 {
matrix A = 2 * A
matrix li A
}
end
Nick
n.j.cox@durham.ac.uk
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of
> xiaotang li
>
> I am now learning to use while looping, but it doesn't
> work for me. I myself can't find any problems with the
> programe and can anyone here point out what mistake I
> made?
>
> For example, I am doing a simple matrix calculation
> like A=2*A and construct the following program
>
> prog define test
> set trace on
> matrix A=J(3,3,1)
> matrix list A
> version 7.0
> local i=1
> while 'i'<5 {
> matrix A=2*A
> local i='i'+1
> }
> end
>
> The Stata just returns as the following and when I
> type 'matrix list A' in the command box, it returns as
> 'matrix A not found', seems nothing is done by Stata.
>
> prog define test
> 1. set trace on
> 2. matrix A=J(3,3,1)
> 3. matrix list A
> 4. version 7.0
> 5. local i=1
> 6. while 'i'<5 {
> 7. matrix A=2*A
> 8. local i='i'+1
> 9. }
> 10. end
> .
> end of do-file
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/