Across in Proc Report
Across in Proc Report
Across in Proc Report
Pharmaceuticals
INTRODUCTION
A common layout of the clinical trial summary table is:
USING ACROSS:
----------- TREATMENT GROUP-------BODY SYSTEM BBODY PREFERRED PLACEBO ( N=88 ) DOSE1 ( N=87 ) DOSE2 ( N=68 ) TOTAL ( N=263 ) MSYSTEM TERM
As introduced in Min Fu's paper, the first step is adding a dummy variable dummy=1 in the given data set. Then submit the following program:
proc report data=sample2 nowd headline headskip spacing=4 split="\"; col body term treat, (value) dummy; define body / group order=data "BODY \ SYSTEM" width=8 left; define term / group order=data "PREFERRED \ TERM" width=14 left; define treat / across order=data "-TREATMENT GROUP- \ " ; define value / " " width=14; define dummy / noprint; break after body / skip; run;
------------------------------------------------------------------------------------------------------------TOTAL BODY1 T TOTAL B BODY1 TOTAL TERM1 TERM2 TERM3 BODY2 B BODY2 TOTAL TERM1 TERM2 TERM3 20 ( 22.7% ) 8 ( 9.1% ) 5 ( 5.7% ) 6 ( 6.8% ) 3 ( 3.4% ) 8 ( 9.1% ) 0 . 6 ( 6.8% ) 3 ( 3.4% ) 0 18 ( 20.7% ) 8 ( 9.2 % ) 6 ( 6.9% ) 0 . 2 ( 2.3% ) 8 ( 9.2 % ) 6 ( 6.9% ) . 2 ( 2.3% ) 12 ( 17.7% ) 6 ( 8.8% ) 0 . 4 ( 5.9% ) 2 ( 2.9% ) 6 ( 8.8% ) 5 ( 7.4% ) 4 ( 5.9% ) 2 ( 2.9% ) 50 ( 20.0% ) 22 ( 8.4% ) 11 ( 4.2% ) 10 ( 3.8% ) 7 ( 2.7% ) 22 ( 8.4% ) 11 ( 4.2% ) 10 ( 3.8% ) 7 ( 2.7% )
The structure of a data set(SAMPLE2) used to produce this summary would be:
BODY INDEX2 TERM INDEX3 TREAT VALUE -------------------------------------------------------------------------------------TOTAL 1 1 PLACEBO 20 ( 22.7% ) TOTAL 1 2 DOSE1 18 ( 20.7% ) TOTAL 1 3 DOSE2 12 ( 17.7% ) TOTAL 1 4 TOTAL 50 ( 20.0% ) BODY1 2 TOTAL 1 PLACEBO 8 ( 9.1% ) BODY1 2 TOTAL 2 DOSE1 8 ( 9.2 % ) BODY1 2 TOTAL 3 DOSE2 6 ( 8.8% ) BODY1 2 TOTAL 4 TOTAL 22 ( 8.4% ) BODY1 3 TERM1 1 PLACEBO 5 ( 5.7% ) BODY1 3 TERM1 2 DOSE1 6 ( 6.9% ) BODY1 3 TERM1 4 TOTAL 11 ( 4.2% ) BODY1 3 TERM2 1 PLACEBO 6 ( 6.8% ) BODY1 3 TERM2 3 DOSE2 4 ( 5.9% ) BODY1 3 TERM2 4 TOTAL 10 ( 3.8% ) ......
--------------------------------------------------------------------------------------------------------------TOTAL BODY1 T TOTAL B BODY1 TOTAL TERM1 TERM2 TERM3 BODY2 B BODY2 TOTAL TERM1 TERM2 TERM3 6 ( 6.8% ) 3 ( 3.4% ) 2 ( 2.3% ) 20 ( 22.7% ) 8 ( 9.1% ) 5 ( 5.7% ) 6 ( 6.8% ) 3 ( 3.4% ) 8 ( 9.1% ) 2 ( 2.3% ) 8 ( 9.2 % ) 6 ( 6.9% ) 18 ( 20.7% ) 8 ( 9.2 % ) 6 ( 6.9% ) 4 ( 5.9% ) 2 ( 2.9% ) 6 ( 8.8% ) 5 ( 7.4% ) 4 ( 5.9% ) 2 ( 2.9% ) 12 ( 17.7% ) 6 ( 8.8% ) 50 ( 20.0% ) 22 ( 8.4% ) 11 ( 4.2% ) 10 ( 3.8% ) 7 ( 2.7% ) 22 ( 8.4% ) 11 ( 4.2% ) 10 ( 3.8% ) 7 ( 2.7% )
NESUG 16
Pharmaceuticals
Compared with the required table in the introduction section, three problems need to be solved. #1. header "---TREATMENT GROUP -----" should only cover PLACE, DOSE1, and DOSE2 columns but not TOTAL column. #2. numbers of patient (N= ) in each group are missing. #3. "0 " is required to fill null cells in the table. ANSWER TO PROBLEM #1. To shift "TREATMENT GROUP" in order not to cover TOTAL column, perform
data _null_; call symput("header", "--TREATMENT GROUP-10)); run; " || repeat(byte(9),
-----TREATMENT GROUP-----BODY SYSTEM PPPREFERRED M TERM PLACEBO ( N= 88 ) DOSE1 ( N=87 ) DOSE2 ( N=68 ) TOTAL ( N=263 )
-------------------------------------------------------------------------------------------
Format $trt is used to add number of patients in each treatment group and the total group in the header. ANSWER TO PROBLEM #3.
proc format; value $value ""=" 0 " ; run; proc report data=sample2 nowd headline headskip spacing=4 split="\"; col body term treat, (value) dummy; define body / group order=data "BODY \ SYSTEM" width=8 left; define term / group order=data "PREFERRED \ TERM" width=14 left; define treat / across order=data "&header \ " format=$trt.; define value / " " format=$value. width=14; define dummy / noprint; break after body / skip; run;
Note: byte(9) is for PC SAS, byte(160) is for SAS on UNIX or other large system.
proc report data=sample2 nowd headline headskip spacing=4 split="\"; col body term treat, (value) dummy; define body / group order=data "BODY \ SYSTEM" width=8 left; define term / group order=data "PREFERRED \ TERM" width=14 left; define treat / across order=data "&header \ " ; define value / " " width=14; define dummy / noprint; break after body / skip; run;
-----TREATMENT GROUP----BODY P PREFERRED PLACEBO DOSE1 DOSE2 TOTAL SYSTEM TE TERM ---------------------------------------------------------------------------
Format $value is added to change null cell in the table to " 0 &header is used to shift the TREATMENT GROUP header to not cover TOTAL column. ANSWER TO PROBLEM #2. To add number of patients (N) under each treatment and total column, the following block of code can be added to generate format $trt. proc sql; create table fmts as select '$trt' as fmtname , treat as start , trim(treat) || '\(N=' || put(count(distinct patno),3.) || ')' as label length=20 from sample1 group by index3, treat; proc format cntlin=sfmt; quit; Note: SAMPLE1 is the original data set used to generate SAMPLE2. With macro variable &header and format $trt,
proc report data=sample2 nowd headline headskip spacing=4 split="\"; col body term treat, (value) dummy; define body / group order=data "BODY \ SYSTEM" width=8 left; define term / group order=data "PREFERRED \ TERM" width=14 left; define treat / across order=data "&header \ " format=$trt.; define value / " " width=14; define dummy / noprint; break after body / skip; run;
".
CONCLUSION:
The technique of using ACROSS usage in the DEFINE statement in PROC REPORT is presented in this paper. Also, the methods of shifting header, adding number of patients under each treatment column, and changing null cells to " 0 " are introduced by coding example. Practicing the algorithm introduced by this paper could save SAS users' coding time and avoid potential mistakes caused by PROC TRANSPOSE.
REFERENCES
SAS Institute, Inc., SAS Technical Report P-222, Changes and Enhancements to Base SAS Software, Release 6.07, Cary, NC. SAS Guide to the SQL Procedure, Usage and Reference, Version 6, First Edition. SAS is a registered trademark or trademark of SAS Institute Inc. in the USA and other countries. indicates USA registration.
ACKNOWLEDGMENTS
I would like to thank Vincent Rabatin for his input and assistance.
CONTACT INFORMATION
Email: [email protected]