Hi, all
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.
What would be the best way of coding this? Attached is hypothetical data. Feel free to expand it.
Thanks!
firm | year | industry | disclose |
a | 2000 | 1 | 0 |
a | 2001 | 1 | 0 |
a | 2002 | 1 | 1 |
a | 2003 | 1 | 1 |
b | 2000 | 1 | 0 |
b | 2001 | 1 | 1 |
c | 2001 | 2 | 0 |
c | 2002 | 2 | 1 |
c | 2003 | 2 | 1 |
c | 2004 | 2 | 1 |
d | 2001 | 2 | 0 |
d | 2002 | 2 | 1 |
d | 2003 | 2 | 0 |
e | 2001 | 2 | 0 |
e | 2002 | 2 | 1 |
e | 2003 | 2 | 1 |
e | 2004 | 2 | 1 |
Lan
From the little I understand, I looks like you want to do this:
data test;
input firm $ year industry disclose;
datalines;
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
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
;
proc sql;
create table disc as
select t1.disclose, t1.industry, t1.firm, t1.year,
mean(t2.disclose) as meanCompetitorDisclosure
from test as t1 left join test as t2
on t1.year=t2.year and t1.industry=t2.industry and t1.firm ne t2.firm
group by t1.disclose, t1.industry, t1.firm, t1.year;
select * from disc;
quit;
proc ttest data=disc;
class disclose;
var meanCompetitorDisclosure;
run;
PG
It sounds like splitting the data is too drastic a step. For example, the mean DISCLOSE for any subset of ONE observations has to be 0. And the mean DISCLOSE for any subset of TWO observations has to be 1. Maybe a better starting point would be to create two summaries: which industry codes have any DISCLOSE=0 observations, and which industry codes have any DISCLOSE=1 observations. It's a little unclear to me whether that should be at the industry code level or the industry code + year level. At any rate, if you were to take your sample data and show what numbers you would like to end up with, that would help.
Good luck.
Hi LanMin,
Is this what you are trying to achieve?
PROC MEANS DATA=HAVE NONOBS NOPRINT NWAY MISSING;
CLASS INDUSTRY;
VAR DISCLOSE;
OUTPUT OUT=WANT (DROP =_:) MEAN=;
RUN;
Regards,
Scott
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
From the little I understand, I looks like you want to do this:
data test;
input firm $ year industry disclose;
datalines;
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
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
;
proc sql;
create table disc as
select t1.disclose, t1.industry, t1.firm, t1.year,
mean(t2.disclose) as meanCompetitorDisclosure
from test as t1 left join test as t2
on t1.year=t2.year and t1.industry=t2.industry and t1.firm ne t2.firm
group by t1.disclose, t1.industry, t1.firm, t1.year;
select * from disc;
quit;
proc ttest data=disc;
class disclose;
var meanCompetitorDisclosure;
run;
PG
thanks so much PG !!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.