Hi,
Could you help me figure out how to calculate percentage by firm and year?
My data looks like...
data test;
input firm year director dummy;
datalines;
1001 2000 aaa 0
1001 2000 bbb 0
1001 2000 ccc 1
1001 2000 ddd 0
1001 2001 aaa 0
1001 2001 bbb 0
1001 2001 ccc 1
1001 2001 ddd 0
1001 2001 eee 0
1002 2005 fff 1
1002 2005 ggg 1
1002 2005 hhh 0
1002 2005 iii 0
1002 2006 fff 1
1002 2006 ggg 0
1002 2006 hhh 1
1002 2006 iii 0
1002 2006 jjj 1
;
run;
I need to get a column (Percentage_MD) having the percentage of MD by firm and year.
Thank you!
And the percentage is calculated how? If it sum of 1 over count of all obs then just use PROC MEANS since the average of a binary variable is the same as the percent.
proc means data=have mean;
by firm year;
var dummy;
run;
How is this column being calculated? You have no variable named MD? Percentage of what...
@hkim3677 wrote:
Hi,
Could you help me figure out how to calculate percentage by firm and year?
My data looks like...
data test;
input firm year director dummy;
datalines;
1001 2000 aaa 0
1001 2000 bbb 0
1001 2000 ccc 1
1001 2000 ddd 0
1001 2001 aaa 0
1001 2001 bbb 0
1001 2001 ccc 1
1001 2001 ddd 0
1001 2001 eee 0
1002 2005 fff 1
1002 2005 ggg 1
1002 2005 hhh 0
1002 2005 iii 0
1002 2006 fff 1
1002 2006 ggg 0
1002 2006 hhh 1
1002 2006 iii 0
1002 2006 jjj 1
;
run;
I need to get a column (Percentage_MD) having the percentage of MD by firm and year.
Thank you!
Oh sorry,
Dummy column is MD.
And the percentage is calculated how? If it sum of 1 over count of all obs then just use PROC MEANS since the average of a binary variable is the same as the percent.
proc means data=have mean;
by firm year;
var dummy;
run;
Sorry, I should have been clearer.
My question here is how to create the column containing the percentage of manager having MD=1 by firm and year.
Then my previous answer was correct.
@hkim3677 wrote:
Sorry, I should have been clearer.
My question here is how to create the column containing the percentage of manager having MD=1 by firm and year.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.