Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: ttest subsample help


From   Clive Nicholas <[email protected]>
To   [email protected]
Subject   Re: st: ttest subsample help
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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index