From | "Michael Blasnik" <[email protected]> |
From | "NEYMOTIN, FLORENCE" <[email protected]> |
To | <[email protected]> |
To | <[email protected]> |
Subject | st: Re: efficiency of coding |
Subject | st: efficiency of coding |
Date | Sun, 17 Jul 2005 21:36:13 -0400 |
I have two questions for you:
<snip>
---------------------------------------------------------------- forvalues i=0(1)2 { tempvar temp`i' egen `temp`i''=median(`w') if `I`i'' gsort -`I`i'' local tempweird=`temp`i'' scalar lw`i'=log(`tempweird')
<snip> } Why not avoid creating the variables? sum `w' if `I`i'',detail scalar lw`i'=r(p50)
(2) If I have two matrices A and B, where A is 15x3, and B is 15x1, and I want to make the third column of A EQUAL to the B matrix, is there a quick way to do this? Right now, I have it replacing value by value in the matrix but I think this is probably slower than it could be.
The code now looks like:
forvalues i=1(1)15{
matrix A[`i' , 3]= B[`i',1]
}
----------------------------------------------------------------
Thanks for your help!
Florence
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |