Clive,
Thanks for the help and sorry that it took so long to write back. I didn't get it to work exacly but I did manage to create the 48 new variables. Now I am trying to loop through all of them to ttest against each other.
I have variables like:
a1 b1 c1 d1
a2 b2 c2 d2
a3 b3 c3 d3
a4 b4 c4 d4
and I want to get all the 1 variables to ttest against each other (6 different ttests) and then all the 2 variables against each other and so on 48 times. Any suggestions?
Sincerely,
Michael
---------- Original Message ----------------------------------
From: Clive Nicholas <[email protected]>
Reply-To: [email protected]
Date: Thu, 19 Apr 2007 13:11:49 +0000 (GMT)
>Michael Macciomei wrote:
>
>hello everyone I am new to stata and I am stuck.
>I am trying to do a simple ttest to see if my means differ significantly. However I have 12 variables that each can be broken down into 4 subcategories (ex. Netincome could be classified as NIsamestate, NIdiffstate, NIsamesector, NIdiffsector)
>I want to compare those 4 against each other and do the same for all 12 variables. So far I have done this:
>
>foreach var of varlist ni-roe{
>gen new`var'=`var' if targetstate==acquirorstate
>}
>
>I did this same command 4 times creating 48 variables.
>Now I want to run a ttest but I have no clue. And was there a simpler way I could have done the above command? Can anyone help?
>
>-----------------------
>
>How about creating a summary variable from your original variables that takes values from 1 to 48 using -egen=group()-, then use -forval- to loop through the t-tests:
>
>. log using mike
>
>. egen typevar=group(groupvars)
>
>. forval i = 1/48 {
> ttest targetvar if typevar==`i', by(catvar)
>}
>
>. log close
>
>Hope that helps,
>Clive Nicholas
>
>
>
>
>
> ___________________________________________________________
>Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
>now.
>http://uk.answers.yahoo.com/
>*
>* 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/
>
*
* 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/