A leading global CRO 1 Effective Use of the RETAIN Statement in Programming Clinical Trial Mingxia Chen Biostatistician Beijing, China.

Slides:



Advertisements
Similar presentations
Haas MFE SAS Workshop Lecture 3:
Advertisements

Copyright © 2006, SAS Institute Inc. All rights reserved. Think FAST! Use Memory Tables (Hashing) for Faster Merging Gregg P. Snell Data Savant Consulting.
How SAS implements structured programming constructs
DIVERSE REPORT GENERATION By Chris Speck PAREXEL International Durham, NC.
SAS Programming:File Merging and Manipulation. Reading External Files (review) data barf; * create the dataset BARF; infile ’s:\mysas\Table7.1'; * open.
Slide C.1 SAS MathematicalMarketing Appendix C: SAS Software Uses of SAS  CRM  datamining  data warehousing  linear programming  forecasting  econometrics.
Outline Proc Report Tricks Kelley Weston. Outline Examples 1.Text that spans columnsText that spans columns 2.Patient-level detail in the titlesPatient-level.
Quick tour of CDISC’s ADaM standard
Chapter 10 Introduction to Arrays
Beginning Data Manipulation HRP Topic 4 Oct 19 th 2011.
Mean Comparison With More Than Two Groups
Two-Way ANOVA in SAS Multiple regression with two or
Hash vs Join A case study evaluating the use of the data step hash object to replace a SQL join Geoff Ness Sep 2014.
Basic And Advanced SAS Programming
Pet Fish and High Cholesterol in the WHI OS: An Analysis Example Joe Larson 5 / 6 / 09.
Jeremy W. Poling B&W Y-12 L.L.C. Can’t Decide Whether to Use a DATA Step or PROC SQL? You Can Have It Both Ways with the SQL Function!
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Topics in Data Management SAS Data Step. Combining Data Sets I - SET Statement Data available on common variables from different sources. Multiple datasets.
Welcome to SAS…Session..!. What is SAS..! A Complete programming language with report formatting with statistical and mathematical capabilities.
SAS SQL SAS Seminar Series
SAS PROC REPORT PROC TABULATE
Clinical Trial Data Validation Using SAS PROC SQL Jie Liu BIOS 524 Project 2003, Fall.
Introduction to SAS Essentials Mastering SAS for Data Analytics Alan Elliott and Wayne Woodward SAS ESSENTIALS -- Elliott & Woodward1.
Introduction to SAS BIO 226 – Spring Outline Windows and common rules Getting the data –The PRINT and CONTENT Procedures Manipulating the data.
Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.
Learning to love the SAS LAG function Phuse 9-12 October 2011 Herman Ament, MSD, Oss NL Phuse 9-12 October 2011.
PREPARING DATA FOR STATISTICAL ANALYSIS Data Cleaning Data Cleaning Dataset Preparation Dataset Preparation Documentation Documentation 9 September 2008.
How to go from an SDTM Finding Domain to an ADaM-Compliant Basic Data Structure Analysis Dataset: An Example Qian Wang, MSD, Brussels, Belgium Carl Herremans,
Multiple Uses for a Simple SQL Procedure Rebecca Larsen University of South Florida.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
1 PhUSE 2011 Missing Values in SAS Magnus Mengelbier Director.
SAS Programmer in Teva Pharmaceuticals Job Description The basic responsibilities are to provide SAS programming support in deriving analysis datasets,
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
Introduction to Using the Data Step Hash Object with Large Data Sets Richard Allen Peak Stat.
Grant Brown.  AIDS patients – compliance with treatment  Binary response – complied or no  Attempt to find factors associated with better compliance.
1 Efficient SAS Coding with Proc SQL When Proc SQL is Easier than Traditional SAS Approaches Mike Atkinson, May 4, 2005.
Research based, people driven CDISC ADaM Datasets - from SDTM to submission CDISC Experience Exchange and ADaM Workshop 15 Dec 2008 Zoë Williams, LEO Pharma.
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Chapter 22: Using Best Practices 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Chapter 5 Reading and Manipulating SAS ® Data Sets and Creating Detailed Reports Xiaogang Su Department of Statistics University of Central Florida.
Chapter 4 concerns various SAS procedures (PROCs). Every PROC operates on: –the most recently created dataset –all the observations –all the appropriate.
Chapter 17: Formatting Data 1 STAT 541 ©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina.
Scientific Method Notes. Scientific Method O Introduction (observe something you want to know about) O Question (a question that can be answered by and.
1 Statistical Software Programming. STAT 6360 –Statistical Software Programming Modifying and Combining Datasets For most tasks we need to work with multiple.
Practical Uses of the DOW Loop Richard Allen Peak Stat April 8, 2009.
Time Series Data Processes by Tai Yu April 15, 2013.
An Introduction Katherine Nicholas & Liqiong Fan.
An Introduction to Proc Transpose David P. Rosenfeld HR Consultant, Workforce Planning & Data Management City of Toronto.
For a programming more efficient Claude Guyot PhUSE 2010 – Berlin Paper CS05.
“LAG with a WHERE” and other DATA Step Stories Neil Howard A.
17b.Accessing Data: Manipulating Variables in SAS ®
Chapter 6: Modifying and Combining Data Sets  The SET statement is a powerful statement in the DATA step DATA newdatasetname; SET olddatasetname;.. run;
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
Beginning Data Manipulation HRP Topic 4 Oct 14 th 2012 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Based on Learning SAS by Example: A Programmer’s Guide Chapters 1 & 2
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 8, 13, & 24 By Tasha Chapman, Oregon Health Authority.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Working Efficiently with Large SAS® Datasets Vishal Jain Senior Programmer.
Longitudinal Data Techniques: Looking Across Observations Ronald Cody, Ed.D., Robert Wood Johnson Medical School.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 16 & 17 By Tasha Chapman, Oregon Health Authority.
MS Access: Creating Advanced Queries
Chapter 6: Modifying and Combining Data Sets
Quick Data Summaries in SAS
Bring the Vampire out of the Shadows: Understanding the RETAIN and COUNT functions in SAS® Steve Black.
Combining Data Sets in the DATA step.
Producing Descriptive Statistics
Creating BDS DERIVED Parameters for a Subject-level Frequency Summary Table? Then this macro can be useful.
Writing Robust SAS Macros
Presentation transcript:

A leading global CRO 1 Effective Use of the RETAIN Statement in Programming Clinical Trial Mingxia Chen Biostatistician Beijing, China

A leading global CRO 2 Introduction RETAIN statement causes a variable that is created by an INPUT or assignment statement to retain its value from one iteration of the DATA step to the next ---- SAS help document In contrast to the default DATA step behavior, without RETAIN statement, SAS automatically sets new variables in the data step to missing at the start of each iterationmissing The RETAIN statement is very useful to perform data manipulation across observations. RETAIN is simpler and more flexible, to speed up your program.

A leading global CRO 3 Example 1 Concatenate character values from multiple records of the same variable

A leading global CRO 4 Original Dataset (SUPPEX) Result Dataset (REASON) USUBJIDIDVARIDVARVALQNAMQLABELQVAL EXSEQ1 EXLOT 1 Lot Number EXSEQ1 EXLOT 2 Lot Number EXSEQ1 EXLOT 3 Lot Number EXSEQ2IIREAS Reason for injection interruption Adverse Event EXSEQ2IISPECSpecify for interruption ALLERGIC REACTION, SKIN RASH, DYSPNEA EXSEQ2 EXLOT 1 Lot Number EXSEQ2 EXLOT 2 Lot Number …… …… USUBJIDEXSEQEXLOTREASON , , Adverse Event: ALLERGIC REACTION, SKIN RASH, DYSPNEA , …… ……

A leading global CRO 5 Original Dataset (SUPPEX) Result Dataset (RSLTDS) EXSEQ 2 IIREAS Reason for injection interruption Adverse Event EXSEQ 2 IISPEC Specify for interruption ALLERGIC REACTION, SKIN RASH, DYSPNEA USUBJIDIDVAR IDVARV AL QNAMQLABELQVAL EXSE Q 1 EXLOT 1 Lot Number EXSE Q 1 EXLOT 2 Lot Number EXSE Q 1 EXLOT 3 Lot Number EXSE Q 2 EXLOT 1 Lot Number EXSE Q 2 EXLOT 2 Lot Number …… …… USUBJIDEXSEQEXLOTREASON , , , …… ……

A leading global CRO 6 PROC SORT DATA=SUPPEX; BY USUBJID IDVAR IDVARVAL QNAM; RUN; DATA RSLTDS(KEEP=USUBJID EXSEQ EXLOT REASON); SET SUPPEX; BY USUBJID IDVAR IDVARVAL QNAM; FORMAT EXLOT REASON $200.; RETAIN EXLOT REASON; IF FIRST.IDVARVAL THEN DO; EXLOT=""; REASON =""; END; IF INDEX(QNAM,“EXLOT")>0 THEN EXLOT=CATX(“, ", OF EXLOT QVAL); IF QNAM IN (“IIREAS", “IISPEC") THEN REASON=CATX(": ", OF REASON QVAL); IF LAST.IDVARVAL; EXSEQ=INPUT(IDVARVAL, best.); RUN; SAS Code Assigns initial value (missing) to EXLOT, REASON Prevents the 2 variables from being reset to missing for each iteration. Concatenates character values of QVAL in multiple records Keeps the last observation per SUBJECT per EXSEQ

A leading global CRO 7 Example 2 Select the previous minimum sum of longest diameters in oncology clinical trials

A leading global CRO 8 Original dataset (TR) USUBJIDVISITNUMVISITTRTESTCDTRTEST TRSTRES N TRSTRES U PRE-TREATMENTSUMLDIAM SUM OF LONGEST DIAMETER 74mm PRE-TREATMENTSUMLDIAM SUM OF LONGEST DIAMETER 94mm TUMOR ASSESSMENT 1 SUMLDIAM SUM OF LONGEST DIAMETER 84mm TUMOR ASSESSMENT 2 SUMLDIAM SUM OF LONGEST DIAMETER 92mm TUMOR ASSESSMENT 3 SUMLDIAM SUM OF LONGEST DIAMETER 106mm PRE-TREATMENTSUMLDIAM SUM OF LONGEST DIAMETER 96mm TUMOR ASSESSMENT 1 SUMLDIAM SUM OF LONGEST DIAMETER 100mm TUMOR ASSESSMENT 3 SUMLDIAM SUM OF LONGEST DIAMETER 95mm PRE-TREATMENTSUMLDIAM SUM OF LONGEST DIAMETER 188mm TUMOR ASSESSMENT 1 SUMLDIAM SUM OF LONGEST DIAMETER 65mm TUMOR ASSESSMENT 2 SUMLDIAM SUM OF LONGEST DIAMETER 66mm TUMOR ASSESSMENT 3 SUMLDIAM SUM OF LONGEST DIAMETER 66mm TUMOR ASSESSMENT 4 SUMLDIAM SUM OF LONGEST DIAMETER 63mm TUMOR ASSESSMENT 5 SUMLDIAM SUM OF LONGEST DIAMETER 61mm …… ……

A leading global CRO 9 Result Dataset (PREMINSL) USUBJID VISITNU M VISIT TRTESTC D TRTEST TRSTRES N TRSTRES U PREMIN SL PRE-TREATMENT SUMLDIA M SUM OF LONGEST DIAMETER 74mm PRE-TREATMENT SUMLDIA M SUM OF LONGEST DIAMETER 94mm TUMOR ASSESSMENT 1 SUMLDIA M SUM OF LONGEST DIAMETER 84mm TUMOR ASSESSMENT 2 SUMLDIA M SUM OF LONGEST DIAMETER 92mm TUMOR ASSESSMENT 3 SUMLDIA M SUM OF LONGEST DIAMETER 106mm PRE-TREATMENT SUMLDIA M SUM OF LONGEST DIAMETER 96mm TUMOR ASSESSMENT 1 SUMLDIA M SUM OF LONGEST DIAMETER 100mm TUMOR ASSESSMENT 3 SUMLDIA M SUM OF LONGEST DIAMETER 95mm PRE-TREATMENT SUMLDIA M SUM OF LONGEST DIAMETER 188mm TUMOR ASSESSMENT 1 SUMLDIA M SUM OF LONGEST DIAMETER 65mm TUMOR ASSESSMENT 2 SUMLDIA M SUM OF LONGEST DIAMETER 66mm TUMOR ASSESSMENT 3 SUMLDIA M SUM OF LONGEST DIAMETER 66mm TUMOR ASSESSMENT 4 SUMLDIA M SUM OF LONGEST DIAMETER 63mm TUMOR ASSESSMENT 5 SUMLDIA M SUM OF LONGEST DIAMETER 61mm63 …… ……

A leading global CRO 10 SAS Code PROC SORT DATA=TR; BY USUBJID TRTESTCD VISITNUM; RUN; DATA PREMINSL(DROP=LASTSL); SET TR; BY USUBJID TRTESTCD VISITNUM; RETAIN PREMINSL ; LASTSL=LAG(TRSTRESN); IF FIRST.TRTESTCD THEN DO; LASTSL=.; PREMINSL=.; END; ELSE PREMINSL=MIN(PREMINSL, LASTSL); RUN; Prevents PREMINSL from being reset to missing for each iterationSets LASTSL to missing for the first visit of each SUBJECTLAG function to Get the value of the last observationSets PREMINSL to missing for the first visit of each SUBJECT Compares PREMINSL to LASTSL in current iteration and resets value if LASTSL is smaller

A leading global CRO 11 Example 3 Count the number of observations (example AE table summary)

A leading global CRO 12 AE Summary Table

A leading global CRO 13 Analysis Dataset (ADAE) TRTANUSUBJIDAESEQAETERMTEAEFLTESAEFLRTEAEFL A CHEILITIS A CONSTIPATIONY A CONSTIPATIONY A CONSTIPATIONY A DIARRHEAY A BACK PAIN (THORACAL)Y Y B ANEMIAY B FEVER WITH CHILLSY B NAUSEAY B PNEUMONIAY Y B ASYMPTOMATIC PULMONAL EMBOLE B LOSS OF APPETITEY Y B NAUSEAY B NEUTROPENIAY B NEUTROPENIAY B PAIN LEFT ILIAC REGION (OS ILIUM) B PAIN RIGHT CALFY Y B WEAKNESSY Y

A leading global CRO 14 SQL Procedure

A leading global CRO 15 Result Dataset (AECNT)

A leading global CRO 16 SAS Code PROC SORT DATA=ADAE; BY TRTAN USUBJID AESEQ; RUN; DATA AECNT(KEEP=TRTAN COL1 COLU1 SUBJCNT EVECNT); SET ADAE; BY TRTAN USUBJID AESEQ; ARRAY AEFL{3} $ TEAEFL RTEAEFL TESAEFL; ARRAY SUBJAE{3} SUBJAE1-SUBJAE3; ARRAY SCNT{3} SCNT1-SCNT3; ARRAY AECNT {3} AECNT1-AECNT3; RETAIN SCNT1-SCNT3 AECNT1-AECNT3 0; IF FIRST.TRTAN THEN DO I=1 TO hbound(SCNT) ; SCNT{I}=0; AECNT{I}=0; END; IF FIRST.USUBJID THEN DO I=1 TO hbound(SUBJAE) ; SUBJAE{I}=0; END; DO I=1 TO hbound(SUBJAE) ; IF AEFL{I}='Y' THEN SUBJAE{I}+1; END; IF LAST.USUBJID THEN DO I=1 TO hbound(SCNT) ; IF SUBJAE{I}>=1 THEN SCNT{I}=SCNT{I}+1; AECNT{I}=AECNT{I}+SUBJAE{I}; END; IF LAST.TRTAN THEN DO I=1 TO hbound(SCNT) ; COL1=I; COLU1=PUT(COL1, COL1F.); SUBJCNT=SCNT{I}; EVECNT=AECNT{I}; OUTPUT; END; RUN; Assigns the 0 for each treatment groupAssigns the initial value (0) of each AE category for each subject Count the number of AEs per SUBJECT for each AE category. Count Number of subject (SCNT{i}) and Number of AEs (AECNT{i} per AE category. Assigns the initial value (0) for the 6 variables Output the Number of subject and Number or events for each category.

A leading global CRO 17 Conclusion The RETAIN statement can carry over values from one observation to next, so it is very useful to manipulate the data across observations.

A leading global CRO 18 Q&A Thanks