Presentation on theme: "DIVERSE REPORT GENERATION By Chris Speck PAREXEL International Durham, NC."— Presentation transcript:
DIVERSE REPORT GENERATION By Chris Speck PAREXEL International Durham, NC
Introduction Diverse Report Generation (DRG) – A dynamic way to produce listings or patient profiles – A new way of thinking about report generation DRG Goals – Automation of large reporting jobs in one macro with minimal code – Synthesis of multiple and disparate datasets – 1-step updates for adding or removing outputs – Easy portability between projects – Potential for expansion of capabilities
Alternative Ways of Reporting Suppose we need to produce patient profile documents with data from 4 datasets. Intuitive: Loop through a macro using Brute Force – Difficult to edit, especially for large jobs – Difficult to transport across studies – Prone to bugs
Alternative Ways of Reporting Loop through a macro using macro logic – Same difficulties as previous example PROC REPORT Data=ADMH PROC REPORT Data=ADAE YES NO LISTING MACRO USING MACRO LOGIC Get/Derive dataset List More datasets ? ADMH? YES NO ADAE ? YES NO PROC REPORT Data=ADVS ADVS ? YES ADEG ? YES NO PROC REPORT Data=ADEG
DRG Method of Reporting Call %MakeReport macro which has only one PROC REPORT and writes code at run time To update program, need only to add new macro calls not new PROC REPORTS YES NO PATIENT PROFILES MACRO USING DRG Get/Derive Patient List More Patients ? MAKE REPORT MACRO %MakeReport Macro Call: ADMH %MakeReport Macro Call: ADAE %MakeReport Macro Call: ADVS %MakeReport Macro Call: ADEG
DRG Method of Reporting How can DRG possibly do this: – with only one PROC REPORT? – while avoiding lengthy macro logic? – With datasets having differing numbers of variables? Column statements would differ across datasets. The number of define statements would differ across datasets. The width of columns would be different for each dataset.
DRG Method of Reporting Five steps: 1.Subsetting data 2.Adding blank observation to datasets if necessary 3.Capturing metadata (variables, labels) from SASHELP.VTABLE 4.Building DEFINE statements into a PROC SQL macro variable 5.Inserting DEFINE macro variable into PROC REPORT PARAMETERS – Dataset name – Variable list – Where statement – Column widths – Autofit flag – Titles and headers
Macro Call Example Note that parameters and their values are arbitrary
Macro Call Example Note that parameters and their values are arbitrary Part of Patient List mentioned on Slides 3 and 4 Optional Parameters
Steps 1-3 Establish macro variables – &DEFINE becomes PROC REPORT define statements – &EMPTY tells PROC REPORT if any observations met the WHERE criteria. Default is N. – &LS resolves to Line Size. For this example, &LS=125. Subset data with WHERE parameter Insert blank observation if dataset is empty – &EMPTY is assigned here. Y if no observations meet WHERE criteria
Step 1: Subset Data The Code: Common sense dataset suffix Keep only variables parameter list RETAIN sorts variables according to parameter list WHERE parameter subsets data
Step 2: Insert Blank Row Insert empty observation into &DS.RPT0 if dataset is empty so PROC REPORT can read it.
Step 2: Insert Blank Row Insert empty observation into &DS.RPT0 if dataset is empty so PROC REPORT can read it. Temporary variable equal to number of observations
Step 2: Insert Blank Row Insert empty observation into &DS.RPT0 if dataset is empty so PROC REPORT can read it. Takes us to MODIFY with no change Temporary variable equal to number of observations
Step 2: Insert Blank Row Insert empty observation into &DS.RPT0 if dataset is empty so PROC REPORT can read it. Takes us to MODIFY with no change Takes us to MODIFY with changes Temporary variable equal to number of observations
Step 2: Insert Blank Row Insert empty observation into &DS.RPT0 if dataset is empty so PROC REPORT can read it. Takes us to MODIFY with no change Takes us to MODIFY with changes Modifies dataset without having to read it into the PDV. Hence no SET statement Temporary variable equal to number of observations
Step 3: Capturing Metadata The Code: Macro logic used because WIDTH and AUTOFIT are optional
Step 3: Capturing Metadata &DS.RPT1 should look something like this: NAMELABELWIDTH MHCATCategory for Medical History20 MHTERM Reported Term for Medical History 30 MHPTT Preferred Term for Medical History 30 MHSTDATStart Date20 MHONGOOngoing?10 What was horizontal is now vertical What would WIDTH be if AUTOFIT=Y?
Step 5: Produce Reports The Code: Inserting variable list, title and header parameters Inserting &DEFINE macro variable as PROC REPORT code Using &EMPTY to provide notice if no observations match WHERE criteria
Error Checking Examples Do datasets and variables exist? Do number of values in WIDTHS and VARS parameters match? Is sum of WIDTH values and appropriate spacing values ≤ &LS? Are WIDTHS and AUTOFIT parameters populated at the same time?
Final Thoughts on DRG Datasets must be pre-programmed, sorted, and ready for reporting Best for profile, listing, or similar reporting in which data has little treatment in PROC REPORT Not best approach if using complex COMPUTE blocks or PROC REPORT to alter data BY, GROUP, ORDER, and BREAK statements can be introduced through additional parameters
Conclusion DRG is an alternative brute force and macro logic automation DRG allows for shorter programming times, more elegant and transportable code By having SAS write code for us, DRG is an effective way to utilize the power of SAS
CONTACT INFORMATION Chris Speck Principal Programmer PAREXEL International, Durham, NC email@example.com