Help using Base SAS procedures

How do I find the number of observations for each year with condition

Reply
New User
Posts: 1

How do I find the number of observations for each year with condition

I have a dataset like that. gvkey is firm identifier

 

gvkeyfyeardvcsharerepurmarketcap
100419907.6512.326224.4604
100419967.9760564.3237
100419989.3757.558540.7748
100419999.2180372.7519
10042012014.6790.0029
1004201411.9151.51046.395
1004201510.418.8842.5112
1019199600.53922.581
101919970.332.97737.41
101919980.3290.50435.604
101920000.335030.378
101920010.3252.29839.721
103419912.7093.759417.3085
103420067.384307.3971038.686

 

From this date table I want to find number of firms, dividend paying firms and repurchasing firms in each year as well as their percentage. The table will look like that:

 

yearnumber of firmsdividend payerspercentage of divident payerrepurchaserspercantege of repurchases
19901458105272.15%35024.01%
1991345285224.68%52315.15%
1992345296527.95%1524.40%
199354991232.24%4528.22%
199452121853.55%85416.39%

 

I can get number of firms  by proc freq but how can I get number of dividend payer and repurchaser?

Super User
Posts: 23,776

Re: How do I find the number of observations for each year with condition


fyuksel wrote:

 

I can get number of firms  by proc freq but how can I get number of dividend payer and repurchaser?


How are you calculating/defining that based on the data you've provided?

PROC Star
Posts: 266

Re: How do I find the number of observations for each year with condition

@fyuksel:

If I understand your question correctly, what you want is something like this:

 

proc sql;
  create table want as select
    year,
    count(*) as no_of_firms,
    sum(DVC>0) as dividend_payers,
    calculated dividend_payers/calculated no_of_firms as pct_dividend_payers format=percent6.2,
    sum(sharerepur>0) as repurchasers,
    calculated repurchasers/calculated no_of_firms as pct_repurchasers format=percent6.2
  from have
  group by year
  order by year
  ;
quit;

   

Ask a Question
Discussion stats
  • 2 replies
  • 142 views
  • 1 like
  • 3 in conversation