Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Corelation matrices
From
Ozgur Ozdemir <[email protected]>
To
Stata <[email protected]>
Subject
st: Corelation matrices
Date
Thu, 3 Nov 2011 10:45:33 +0000
Hi,
I am using Stata 10 and have an issue with correlations. I have a list of companies (2500 of them) with several variables. Each company is on a different row. The variables are based on different years with a year suffix at the end. For example, Sales_2010, Sales_2009, Sales_2007....R&D_2010, R&D2009.... etc. I have a script to mark the outliers and this script is creating 10 new fields such as Y2000, Y2001, Y2002 and outliers are marked for each year separately. So, when i look at the text written on any Y variable i can see that why a specific company is outlier on a specific year. if I find text "first" on a specific company for a year, that means the company is not an outlier.
Now, I would like to get some correlations without outliers and run the correlate command however when I run the correlate command it should look at the different years of Y variables and give me the full list of correlations. For example, I would like to run correlation between all years of Sales and R&D so i need to use foreachvalues command which will trace each year for two specific variables then I can get the full correlation matrices e.g covering Sales and R&D from 2000 to 2010. However, this is doing individual correlations one by one.
forvalues
i=2000/2010 {
forvalues j=2000/2010 { correlate sales_`i' rd_`j'
if Y`i'=="first" & Y`j'=="first" } }
any idea how I can get a full correlation matrix between those tow variables and easily export back to excel?
kind regards
Ozgur Ozdemir
E: [email protected]
Skype : ozgurozdemir2005
*
* 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/