Skip to content

Instantly share code, notes, and snippets.

@JoostImpink
Created May 13, 2016 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JoostImpink/b855b0eae2f7e5acef2a170af5a9151f to your computer and use it in GitHub Desktop.
Save JoostImpink/b855b0eae2f7e5acef2a170af5a9151f to your computer and use it in GitHub Desktop.
Hayn 1995 replica, table 2
/* Table 2
Use firms that have at least 8 years of data
Count the number of loss-years
*/
/* For each gvkey, count the #loss-years */
proc sql;
create table d_table2_a as
select gvkey, sum(loss) as lossYears from b_sample
/* gvkey must be in the following table */
where gvkey IN (
/* get gvkey from a table */
select gvkey from (
/* cook the table on the spot */
/* count the number of years for each gvkey */
select gvkey, count(*) as numYears
from b_sample
group by gvkey
/* only if numyears is 8 or more, keep in result */
having numYears >= 8
)
)
group by gvkey;
quit;
proc format;
value myCountFormat
/* If 10 or higher */
10-100 = '10 or more'
/* Other values */
other = [best.];
run;
/* Using proc freq */
proc freq data=d_table2_a;
tables lossYears / out=d_table2_b;
/* Apply the format */
format lossYears myCountFormat.;
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment