Hi!
I'm using SAS 9. I am replicating a paper, and I am trying to show that my results are comparable to the results in the paper with a side-by-side table. See picture below for an example. In the example, my results would be the "Our Replication" section and the results I'm referencing would go into the "Cooper and Boynton (2004)" section.
My question is - is it possible to append columns with hard-coded numbers to a table using proc tabulate? Is there a better way to do this?
Code for the portion of the table displaying my results:
PROC FORMAT;
VALUE lossfirm 0="Non-Loss Firm"
1="Loss Firm" ;
RUN;
proc tabulate data=x1;
title 'Replication';
class lossfirm;
var at ti ni;
table at='Total Assets ($millions)'*(N*F=COMMA.0 MEAN*F=COMMA.0) ti='Taxable Income ($millions)'*(MEAN*F=COMMA.0) ni='Net Income ($millions)'*(MEAN*F=COMMA.0) ,
(lossfirm='' ALL='All Firms') ;
FORMAT lossfirm lossfirm.;
run;
You can construct synthetic data that would produce the Cooper/Boynton statistics. Adding a new variable STUDY (= 'Cooper and Boynton (2004)' or 'Our Replication') and using STUDY as a new class variable, should do the trick:
data combined (drop=i _:);
set x1 end=end_of_x1;
retain study "Our Replication ";
output;
if end_of_x1;
infile datalines;
study='Cooper and boynton (2004)';
input lossfirm _n at ti ni _nall _atall _tiall _niall ;
do i=1 to _n;
output; ** Output loss firms **;
end;
/* ******** Gen at,ti,ni (x) for non-loss firms ****** */
/* We know that _nall*_atall = _n*at + (_nall-_n)*x */
/* ==> (_nall-_n)*x = _nall*_atall - _n*at */
/* ==> x = (_nall*_atall - _n*at)/(_nall-_n) */
at = (_nall*_atall - _b*at)/(_nall-_n);
ti = (_nall*_tiall - _b*ti)/(_nall-_n);
ni = (_nall*_niall - _b*ni)/(_nall-_n);
do i=1 to (_nall-_n);
output;
end;
datalines;
1 9088 4303409 -159907 -159107 27384 26100649 442705 322621 ;
run;
What I don't understand is how you got tabulate to drop the non-loss firm columns. But ignoring that, notice how the program imputes the values for the non-loss firms that would replicate the values for ALL firms.
You should be able to apply proc tabulate to the COMBINED data set.
You may be better off summarizing the data. Then use Proc Report for display.
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.