BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kmardinian
Quartz | Level 8

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Hi:
My paper and the accompanying zip file of programs shows 3 different ways to create a demographic report similar to this. You don't show any of your PROC REPORT statements or tell us your destination of interest. My suggestion is that you review the paper and the programs in the zip file. Look here, under 2008 for the paper entitled Creating Complex Reports: https://support.sas.com/rnd/papers/#SGF2008 (scroll down to find the paper title -- there are 2 links on the page -- one for the paper and one for the zip file.

Cynthia

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

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.

Cynthia_sas
SAS Super FREQ
Hi:
My paper and the accompanying zip file of programs shows 3 different ways to create a demographic report similar to this. You don't show any of your PROC REPORT statements or tell us your destination of interest. My suggestion is that you review the paper and the programs in the zip file. Look here, under 2008 for the paper entitled Creating Complex Reports: https://support.sas.com/rnd/papers/#SGF2008 (scroll down to find the paper title -- there are 2 links on the page -- one for the paper and one for the zip file.

Cynthia
kmardinian
Quartz | Level 8

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!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1317 views
  • 0 likes
  • 3 in conversation