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

st: Re: vectors in STATA


From   "Scott Merryman" <[email protected]>
To   <[email protected]>
Subject   st: Re: vectors in STATA
Date   Thu, 12 Dec 2002 19:56:07 -0600

----- Original Message -----
From: "Alejandro Ria�o" <[email protected]>
To: <[email protected]>
Sent: Thursday, December 12, 2002 6:11 PM
Subject: st: vectors in STATA


> Hi Statalisters,
> I used to program in Gauss, that's why I still think
> about matrixes and vectors when I'm doing my own
> programs. My question is the following
>
> I want to store the correlation between 2 variables by
> each pair of countries and then store this number(that
> would be r(rho)) in a vector, so at the end I would
> have a column with the correlation for each in pair of
> countries as a position in this vector.
>
> Do you know how can i do this in STATA ???
>
There is probably a better way to do this, but here is one method

levels countries, local(levels)
matrix A = 1
foreach x of local levels {
 qui corr var1 var2  if rep == `x'
 scalar rho`x' = r(rho)
 matrix a`x' = rho`x'
 matrix A = A \ a`x'

 }
matdelrc A, r(1)


Scott


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