thanks to both of you. Scott, your code is not what I want exactly. i paste my question again here, and give an example (see ********** in the end): My unit of analysis is firm-year. main interest is variable disclose (binary 0,1). First, I will partition the sample into two sets : set ONE contains firm-year observations that have disclose=0, and set TWO contains firm-year observations that have disclose=1, What I want to know is : for set ONE observations that share the same industry code with set ONE observations, what is the mean value of disclose, Similarly, for set TWO observations that share the same industry code with set ONE observations, what is the mean value of disclose, that is, I try to show whether industry peers in set ONE are more or less likely to disclose compared with industry peers in set TWO. *************** example: My original data would be partition into disclose =0 firm year industry disclose a 2000 1 0 a 2001 1 0 b 2000 1 0 c 2001 1 0 d 2001 2 0 d 2002 2 0 e 2001 2 0 disclose =1 firm year industry disclose a 2002 1 1 a 2003 1 1 b 2001 1 1 c 2000 1 1 c 2002 1 1 c 2003 1 1 c 2004 1 1 d 2002 2 1 e 2002 2 1 e 2003 2 1 e 2004 2 1 for firm a in year 2000, industry=1, it has 2 competitors in year 2000, b and c, b's disclose=0 and c's disclose=1, so what I want is to output the average disclose value of these two competitors as 0.5. what I want as final results is a table with mean values in 2 cells below, disclose =1 disclose =0 peers average diclose value then do a t-test to see if peers are more or less likely to disclose in each subsample (i.e. disclose =1 vs. disclose =0 subset).. thanks, Lan
... View more