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

st: RE: Copying matrices


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   st: RE: Copying matrices
Date   Mon, 19 Aug 2002 09:35:42 -0400

> -----Original Message-----
> From: [email protected] [mailto:[email protected]] 
> Sent: Monday, August 19, 2002 9:27 AM
> To: [email protected]
> Subject: st: Copying matrices
> 
> 
> 
> > -----Original Message-----
> > From:	Fergusson, Chris (WPH Cancer Registry) 
> > Sent:	19 August 2002 14:25
> > To:	'[email protected]'
> > Subject:	Serial number:  1970515440
> > 
> > I have a program which produces a matrix (easr) size x*1 
> where x is even,
> > no larger than 32 and variable depending on user input.  I 
> need to take
> > the first x/2 observations enclosed in the matrix and save 
> them in another
> > matrix (botheasrm) and the second x/2 observations need to 
> go in another
> > matrix (botheasrf).  To correctly do the first part I used the code
> > 
> > matrix define botheasrm = J(`count'/2, 1, 0)
> > 
> > forvalues i = 1/`z' { 
> > 	forvalues j = 1/1 { 
> > 		matrix botheasrm[`i',`j']= easr[`i',`j'] 
> > 	} 
> > 
> > where z is x/2 previously defined.  However I am having 
> trouble copying
> > the second half of the matrix and any help would be appreciated.
> > 
> > Thanks in advance,
> > Christopher D Fergusson

I'm not totally sure what you are trying to do here, but if you are just
trying to split the easr matrix in half, you can do this as follows.  

	matrix botheasrm = easrm[1..`z',1]
	local z1=`z'+1
	matrix motheasrf = easrm[`z1'...,1]

See "submatrix extraction" under -help matrix-.

Nick Winter
*
*   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