Never Cut and Paste Again How to Automate Results with ODS PowerPoint, Metadata and Macros
What’s the Problem? SAS creates dataset, reports, charts, etc. Clients (internal and external) want presentations Clients always want report re-run Cutting, pasting, and re-formatting is: Time consuming Error prone Boring…
Learning Objectives Create PowerPoint® files using the SAS® PowerPoint ODS Create macros to automatically calculate descriptive statistics on all variables in a dataset using the DICTIONARY.COLUMNS dataset Send reporting elements (tables and chart) to PowerPoint presentation files
Outline Healthcare claims data structures Create fact tables from healthcare data Create results table with descriptive statistics Create PowerPoint file Create tables in PowerPoint using PROC REPORT Create charts in PowerPoint using PROC SGPLOT
What’s In, What’s Out Conference white paper has a step-by-step walkthrough of all of the code Presentation will touch on the key concepts and syntax
Healthcare Data Structures Paid bills (aka administrative claims data) Transactional data One observation per claim Disparate dataset Pharmacy Claims (e.g. paid bills for prescriptions) Medical Claims (e.g. paid bills for hospital stay)
Create Fact Table From Healthcare Data Commonly used in data warehouses Create a single observation per entity (patient) Add study measures Total paid Total Claims etc.
Create Fact Table From Healthcare Data PROC SQL; CREATE TABLE Fact AS SELECT PatientID, DateOfBirth , Gender FROM Medical UNION SELECT FROM Pharmacy ; QUIT;
Limitations of Variable Names Too Short (32 characters) Limited Character Set (no spaces, leading number, etc.) e.g. Baseline Allowed Amount Per Member Per Month for Inpatient Hospitalizations Due to Chronic Obstructive Pulmonary Disease becomes BaseAAPMPMInptHospCOPD
Variable Label Property 256 Characters Larger character set DATA Fact; SET Fact; ATTRIB DateOfBirth LABEL = "Date Of Birth" ; RUN;
Overloading the Variable Name Overloading the variable name with a prefix BASE_ for Baseline data FLUP_ for Follow Up data Used by macro to identify reportable values
Study Measure Macros Builds a reusable library %Macro AssignRxCount(Dataset=); *Create Variable with a Label; DATA &Dataset; SET &Dataset; ATTRIB FLUP_RxCount LENGTH = 8 FORMAT = COMMA9. LABEL = "Total Number of Prescriptions"; RUN; *Populate the Fact table value; PROC SQL; UPDATE &Dataset f SET FLUP_RxCount = ( SELECT COUNT(AmountPaid) FROM Pharmacy p WHERE p.PatientID = f.PatientID); QUIT; %mend; Builds a reusable library Couples the variable creation and population Iterate through the measures
Completed Fact Table
Iterate Through Metadata proc sql ; SELECT Name, Type INTO :MeasureVariable1-MeasureVariable9999, :MeasureType1-:MeasureType9999 FROM DICTIONARY.Columns WHERE LibName = "&FactLib" and MemName = "&FactDS" AND (Name like"BASE%" or Name like"FLUP%") ; quit; %let MeasureCounter = &SqlObs; %DO ctr = 1 %to &MeasureCounter; … %END DICTIONARY.COLUMNS contains every variable in every dataset in every library Load each variable name and type into an array Loop through the array and summarize the data
Summarize Based on Data Type %IF &&MeasureType&ctr = char %then %do; %AddCategoricalResults( Library=&FactLib, Dataset=&FactDS, Variable=&&MeasureVariable&ctr ); %end; %else %if &&MeasureType&ctr = num %then %AddContinuousResults( Call a different summarizing macro based on the data type char data = #(%) num data = Mean(median)[SD]
Results Table
Advantages of Results Table PowerPoint generation is independent of fact table variables Everything needed is in the results table Results formatting is completed, no need to check metadata All project-specific data structures have been translated into a standard format
Create PowerPoint file Two statements are minimum Any PROC sending data to the results window will send results to PowerPoint …but the devil is in the details… ODS PowerPoint ; /* Any PROC sending output to the results window */ ODS PowerPoint Close;
PowerPoint ODS Lessons Learned FILE = <Any Valid File Path> LAYOUT=TitleAndContent OPTIONS PAPERSIZE=(10in 5.63in) Control other style properties in PROCs vs. PowerPoint ODS Wide PowerPoint Tables => $()*#&@!! Control width with font size
Output Results with Data Type Specific Macros Create a separate macros for Numeric Character Can be expanded to consider Format Currency Dates pValue Nominal vs. Ordinal Distribution
White Paper Code Output Sample
White Paper Code Output Sample
Sample from Magellan Method Different colored header section Banded rows Custom column headers with population sizes Bolded rows for significant p values
Conclusions Variable labels, formats and overloaded variable names can be used by macros to automate descriptive statistics for dozens, even thousands of measures ODS PowerPoint can be used to send the results of any PROC to a PowerPoint file Tables with PROC REPORT or PROC TABULATE Charts with PROC SGPLOT
Contact Information Name: Ted D. Williams, PharmD, BCPS Company: Magellan Method City/State: Middletown, RI Phone:314.387.4305 Email:tdwilliams1@magellanhealth.com