OASUS Spring or Fall YYYY Lihsin Hwang Statistics Canada Thursday, November 15, 2018 May the Force Be with Your Clients A simple trick to create Excel pivot tables without crunching data inside-out Lihsin Hwang Statistics Canada First & last name Company name
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Agenda Assumptions Steps to create pivot tables Demo Other options and issues First & last name Company name
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Assumption Pivot tables are well known and popular ODS (Output Delivery System) are well known and popular Creative Customers First & last name Company name
Step I – Prepare you data OASUS Spring or Fall YYYY Thursday, November 15, 2018 Step I – Prepare you data No need to fully understand your data Dummy variable – COUNT Constant value of ‘1’ data cars; set sashelp.cars; count=1; run; First & last name Company name
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Step 2 – Link XML file Link an external file in XML format FILENAME statement filename tfile "c:\temp\Input_Pivot.xml"; First & last name Company name
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Step 3 – ODS output Using ExcelXP tagsets Setting only one option (optional) (default value: “Table 1: dataset name”) ods tagsets.ExcelXP file=tFile; ods tagsets.ExcelXP options(sheet_label='Source Data'); proc print data=cars noobs label; run; ods tagsets.ExcelXP close; First & last name Company name
Step 4 – Open/Close XML file 15/11/2018
Step 5 – Add a pivot table 15/11/2018
Step 6 – Use the dummy variable 15/11/2018
Step 7 – Drag and drop 15/11/2018
Step 8 – Hide and save (safe!) Save the file in XLSX format (optional) Hide the source data sheet prevent any unnecessary human intervention to the source data 15/11/2018
The force is with your client now! OASUS Spring or Fall YYYY Thursday, November 15, 2018 The force is with your client now! First & last name Company name
Other solution and issue OASUS Spring or Fall YYYY Thursday, November 15, 2018 Other solution and issue Using of tableeditor tagsets ods tagsets.tableeditor file="&resultsHome\example1.html" options( button_text = "Create PivotTable" auto_excel = "yes" pivotrow = "product_line" pivotcol = "quarter" pivotdata = "profit" pivotpage = "year" excel_save_file="&JavaResultsHome\example1.xlsx" quit="NO" ); Title1 "Example 1 - Create the First Pivot Table"; proc print data=data.sales; run; ods tagsets.tableeditor close; Last begin with our first step First & last name Company name
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Another solution ODS Excel (9.4 Only) data cars; set sashelp.cars; count=1; run; ods excel file="c:\temp\example1.xlsx" options(sheet_label='Source Data'); proc print data=cars; ods excel close; Last begin with our first step First & last name Company name
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Pros and Cons Pros No need to crunch data inside-out Fastest way to provide basic pivot tables Cons Automation – not feasible You only need to provide basic PivotTables and the users will quickly learn to exploit them on their own. First & last name Company name
OASUS Spring or Fall YYYY Thursday, November 15, 2018 Resources Parker, Chevell. (2010). Using SAS® Output Delivery System (ODS) Markup to Generate Custom PivotTable and PivotChart Reports, SAS Institute Inc. Eberhardt, Peter. , & Kong, Louanna. (2012). The Armchair Quarterback: Writing SAS® Code for the Perfect Pivot (Table, That Is), Vanam, Mahipal., & Karidi, Kiran., & Dodlapati, Sridhar. (2010). SAS to Excel with ExcelXP Tagset. First & last name Company name
OASUS Spring or Fall YYYY Questions / Comments Thursday, November 15, 2018 Lihsin Hwang System Engineering Division Statistics Canada (613) 799-6952 Lihsin.Hwang@statcan.gc.ca First & last name Company name