Hi, I am trying to create a customized table based on simple analyses I completed in SAS and I am not sure how to create the custom column titles and row titles in the proc report statement. This is what I have so far and I have attached an image of what the top row should look like. The below code may be wrong, I just wasn't sure how else to go about it. Any advice is appreciated!
data row1;
length rowlabel $100 col_1 col_2 col_3 col_4 $32 ;
rowlabel='Aronchick Scored Bowel Cleansing - Insertion:';
col_1='ECP';
col_2='MoviPrep';
col_3='Total';
col_4='ECP-MoviPrep';
roworder=1;
run;
proc summary data=t2 nway completetypes;
class trt;
output out=BigN (drop=_type_ rename=(_freq_=bigN) index=(trt))/levels;
run;
proc transpose data=BigN out=bignumber;
var bign;
run;
data row2;
length rowlabel $100 col_1 col_2 col_3 col_4 $32 ;
set bignumber;
rowlabel='n';
col_1=strip(put(col1, 8.0));
col_2=strip(put(col2, 8.0));
col_3=strip(put(col3, 8.0));
roworder=2;
run;
proc freq Data=t2;
table trt*outcome;
exact binomial riskdiff;
output out=freq (keep=xl_rsk12 xu_rsk12 xl_rsk22 xu_rsk22 xl_rsk2 xu_rsk2
_rdif2_ xl_rdif2 xu_rdif2) riskdiff binomial;
run;
data row4;
length rowlabel $100 col_1 col_2 col_3 $32 ;
set freq;
rowlabel=' 95% CI^{super 2}';
col_1='['||strip(put(xl_rsk12*100, 8.1))||'%, '||strip(put(xu_rsk12*100, 8.1))||'%]';
col_2='['||strip(put(xl_rsk22*100, 8.1))||'%, '||strip(put(xu_rsk22*100, 8.1))||'%]';
col_3='['||strip(put(xl_rsk22*100, 8.1))||'%, '||strip(put(xu_rsk22*100, 8.1))||'%]';
col_4='';
roworder=4;
run;
data row5;
length rowlabel $100 col_1 col_2 col_3 col_4 $32 ;
set freq;
rowlabel=' Risk Difference (95% CI)^{super 3}';
col_4=strip(put(_rdif2_, 8.3))||' ['||strip(put(xl_rdif2, 8.3))||', '||strip(put(xu_rdif2, 8.3))||']';
col_1=''; col_2=''; col_3='';
roworder=5;
run;
data num_prop;
set t2;
comnum=1;
if rowlabel='SUCCESS';
rowlabel=' n (proportion)';
run;
proc sort;
by comnum;
run;
data bignumber_vorder;
set bignumber;
comnum=1;
drop _name_;
rename col1=bigcol1 col2=bigcol2 col3=bigcol3;
run;
data row3;
retain rowlabel col_1 col_2 col_3 col_4;
merge num_prop bignumber_vorder;
by comnum;
if col_1 ne '0(0.0)' then col_1=cat(strip(put(col_1,8.0)),' (', strip(put((col_1/bigcol1)*100,8.1)) ,'%)');
else col_1=col_1;
if col_2 ne '0(0.0)' then col_2=cat(strip(put(col_2,8.0)),' (', strip(put((col_2/bigcol2)*100,8.1)) ,'%)');
else col_2=col_2;
if col_3 ne '0(0.0)' then col_3=cat(strip(put(col_3,8.0)),' (', strip(put((col_3/bigcol3)*100,8.1)) ,'%)');
else col_3=col_3;
col_4=' ';
roworder=3;
run;
data all_vorder;
set title num_prop row4 row5;
run;
data all_vorder;
length rowlabel $100 col_1 col_2 col_3 col_4 $32;
rowlabel=' n(Proportion)';
col_1='0 (0.0%)';
col_2='0 (0.0%)';
col_3='0 (0.0%)';
col_4='';
roworder=2;
run;
To get an answer:
1. Provide simple data example
2. Provide an example of the expected output for that data, including an explanation of how values are derived.
3. It is better to have all this inline rather than as attachments.
I was able to figure it out using different data steps to create the rows I needed, but I will definitely take a look at the paper you've attached for the next time I will have to do this. Thank you for your help!
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.