Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: re: while looping


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: re: while looping
Date   Wed, 20 Aug 2003 10:23:48 +0100

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 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]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/



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