# st: RE: How to store the covariance values for further manupulations

 From "Kieran McCaul" To Subject st: RE: How to store the covariance values for further manupulations Date Sat, 22 Aug 2009 05:08:39 +0800

```....

I don't know how your country variables is coded, but let's assume you
had twenty countries coded 1 to 20, then the following will create a new
variable, cov, that contains the covariance between var1 and var2 for
each country.  It's a bit inelegant, but it will at least show how you
can save the covariances.

gen cov=.
forvalues i=1/20 {
corr var1 var2 if country==`i', c
replace cov = `r(cov_12)' if country==`i'
}

______________________________________________
Kieran McCaul MPH PhD
WA Centre for Health & Ageing (M573)
University of Western Australia
Level 6, Ainslie House
48 Murray St
Perth 6000
Phone: (08) 9224-2701
Fax: (08) 9224 8009
email: Kieran.McCaul@uwa.edu.au
http://myprofile.cos.com/mccaul
http://www.researcherid.com/rid/B-8751-2008
______________________________________________
If you live to be one hundred, you've got it made.
Very few people die past that age - George Burns

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of mariam ouchen
Sent: Saturday, 22 August 2009 2:07 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: How to store the covariance values for further
manupulations

Good day statalisters
Actually I'm faced with a problem, I'm using the command  by country:
corr var1 var2, Cov to obtain the matrix variance covariance,
but what i'need is the covariance values to compute sqrt(-2cov), how
can'i do this ?how can'i store the covariance values for my
manupulation?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```