Build your Metadata with PROC CONTENTS and ODS OUTPUT Louise S. Hadden Abt Associates Inc.

Slides:



Advertisements
Similar presentations
When Good Looks Arent Enough Lisa Eckler. When Good Looks Arent Enough.
Advertisements

Copyright © 2008 SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks.
Axio Research E-Compare A Tool for Data Review Bill Coar.
© Paradigm Publishing, Inc Excel 2013 Level 2 Unit 2Managing and Integrating Data and the Excel Environment Chapter 7Automating Repetitive Tasks.
Tutorial 8: Developing an Excel Application
5/1/ Quick and Dirty Excel® Workbooks Without DDE or ODS Andrea Zimmerman, Capital One, Richmond, VA.
Tutorial 12: Enhancing Excel with Visual Basic for Applications
How to Create a Custom Style Sonia Extremera / Antonio Nieto / Javier Gómez PhUSE Annual Conference, 9th-12th Oct 2011, Brighton UK.
Get Fancy Department Level Reports Using SAS ExcelXP Tagset 2008 AIR Forum Seattle, Washington Ray Wallace Washington State University.
Introduction to SQL Session 1 Retrieving Data From a Single Table.
Let SAS Do the Coding for You! Robert Williams Business Info Analyst Sr. WellPoint Inc.
Microsoft Office Word 2013 Expert Microsoft Office Word 2013 Expert Courseware # 3251 Lesson 4: Working with Forms.
Exploring Microsoft Excel 2002 Chapter 8 Chapter 8 Automating Repetitive Tasks: Macros and Visual Basic for Applications By Robert T. Grauer Maryann Barber.
Microsoft Office Excel 2013 Expert Microsoft Office Excel 2013 Expert Courseware # 3254 Lesson 6: Protecting and Configuring Workbooks.
Software Apps. Word, PowerPoint, Excel, Access Mr. Miller.
Copyright © 2010, Meta-Xceed, Inc. All rights reserved. BI Flash and all other Meta-Xceed Inc. product or service names are registered trademarks or trademarks.
Copyright © 2006, SAS Institute Inc. All rights reserved. Enterprise Guide 4.2 : A Primer SHRUG : Spring 2010 Presented by: Josée Ranger-Lacroix SAS Institute.
A Concise Display of Multiple Response Items Patrick Thornton.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 4 – Creating New.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 7 BACKNEXTEND 7-1 LINKS TO OBJECTIVES Record & run a macro Record & run a macro Save as a macro-
Spreadsheets in Finance and Forecasting Presentation 9 Macros.
Niraj J. Pandya, Element Technologies Inc., NJ.  Summarize all possible combinations of class level variables even if few categories are altogether missing.
Report Management Using the ODS DOCUMENT Destination and Report Metadata Brit Harvey February 2010.
Definitions. Cell: Cell: Space in the intersection of a column (vertical division) and a row (horizontal division). Row: Row: A row runs horizontally.
My ODS: Real-World Uses of Modifying Table Templates Steve James Centers for Disease Control and Prevention Atlanta, Ga.
Multiple Uses for a Simple SQL Procedure Rebecca Larsen University of South Florida.
%rtf2data: A utility macro to convert RTF Table to SAS® dataset
Copyright © 2008 SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks.
Essential ODS PDF Patrick Thornton.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
Advanced Lesson 5: Advanced Data Management Excel can import data, or bring it in from other sources and file formats. Importing data is useful because.
1 Back Up with Each Submit One approach for keeping a dynamic back up copy of your current work.
M AKE E ASY S TYLE T EMPLATES U SING SAS M ACRO Barbara Harlan.
Computer Literacy BASICS: A Comprehensive Guide to IC 3, 5 th Edition Lesson 19 Organizing and Enhancing Worksheets 1 Morrison / Wells / Ruffolo.
Define your Own SAS® Command Line Commands Duong Tran – Independent Contractor, London, UK Define your Own SAS® Command Line Commands Duong Tran – Independent.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® Excel 2010 © 2011 The McGraw-Hill Companies,
SAS ODS (Output Delivery System) Donald Miller 812 Oswald Tower ;
1 Chapter 7: Customizing and Organizing Project Results 7.1 Combining Results 7.2 Updating Results 7.3 Customizing the Output Style (Self-Study)
Copyright © 2010, SAS Institute Inc. All rights reserved. SAS ® Using the SAS Grid.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
1 Chapter 3: Getting Started with Tasks 3.1 Introduction to Task Dialogs 3.2 Creating a Listing Report 3.3 Creating a Frequency Report 3.4 Creating a Two-Way.
Customize SAS Output Using ODS Joan Dong. The Output Delivery System (ODS) gives you greater flexibility in generating, storing, and reproducing SAS procedure.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
Do not put content on the brand signature area NOBS for Noobs David B. Horvath, CCP, MS PhilaSUG Winter 2015 Meeting NOBS for Noobs.
PROC CATALOG The Wish Book SAS® Procedure. 2 PROC CATALOG, the Wish Book SAS® Procedure Louise S. Hadden Abt Associates Inc. PROC CATALOG, the Wish Book.
ODS TAGSETS - a Powerful Reporting Method Derek. 2 Agenda Understanding the tagset How to use tagsets Conclusion.
Copyright © 2008, SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks.
Use SAS to Automate Hospital Reports generation Cardiac Service BC Stats Team, PHSA Tina Yang.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
Lesson 17 Mail Merge. Overview Create a main document. Create a data source. Insert merge fields into a main document. Perform a mail merge. Use data.
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Copyright © SAS Institute Inc. All rights reserved. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks.
Better Metadata Through SAS® II: %SYSFUNC, PROC DATASETS, and Dictionary Tables.
Microsoft Excel Consolidation. Contents Introduction to Multiple Workbook Applications Working with Multiple Workbook Applications using normal keyboard.
Beautiful PROC CONTENTS Output Using the ODS Excel Destination Suzanne Dorinski SESUG 2015 Disclaimer: Any views expressed are those of the author and.
Extreme SAS® reporting II: Data Compendium and 5 Star Ratings Revisited Louise S. Hadden Abt Associates Inc.
Using SAS to Create Multi-Sheet Excel Workbooks
Advantages of sas for reporting
Using ODS Excel Migrating from DDE to ODS
Poster Title Author #1 name, ABC Corporation, City, Country Author #2 name, ABC Corporation, City, Country Abstract A brief abstract at the beginning summarizes.
A brief introduction to the topic
Poster Title Author #1 name, ABC Corporation, City, Country Author #2 name, ABC Corporation, City, Country Abstract A brief abstract at the beginning summarizes.
OASUS Spring or Fall YYYY Lihsin Hwang Statistics Canada
Exploring Microsoft Excel
PROC DOC III: Self-generating Codebooks Using SAS®
Beautiful PROC CONTENTS Output Using the ODS Excel Destination
Automate Repetitive Programming Tasks: Effective SAS® Code Generators
Microsoft Excel 2007 – Level 2
Presentation transcript:

Build your Metadata with PROC CONTENTS and ODS OUTPUT Louise S. Hadden Abt Associates Inc.

Definitions met·a·da·ta ˈmetəˌdatə,-ˌdātə/ noun 1.a set of data that describes and gives information about other data

Definitions ODS Output Objects: Most SAS procedures generate ODS objects behind the scenes. SAS uses these objects in conjunction with style templates that have custom “buckets” for certain types of output to produce the output we see in all destinations.

Definitions The task at hand: create an Excel Workbook with data set information on multiple data sets in multiple worksheets, all within your SAS program, with no user intervention. Oh, and could you just add an index of the files reported on as the first worksheet?

Choices 1.Use ODS to output PROC CONTENTS OUTPUT 2.Use PROC CONTENTS OUT= and output the result to ODS 3.Use ODS Output Objects and output to ODS There are pros and cons to each approach.

Using ODS Objects 4 easy pieces Identify / locate your ODS output object(s) using ODS TRACE. Output your ODS output object(s) and view them by using basic SAS procedures. Manipulate your ODS output object(s) using SAS. Report on your final data set to ODS.

ODS TRACE ODS TRACE ON / LABEL; PROC CONTENTS DATA=LIB.YOURDATA; RUN; ODS TRACE OFF;

Output ODS OUTPUT ATTRIBUTES=atr VARIABLES=var SORTEDBY=sortedby&infi.; PROC CONTENTS DATA=&inlib..&infi ; RUN; ODS OUTPUT CLOSE;

Analyze

Create Variable Listing File PROC SORT DATA=var; BY num; RUN; DATA &infi; SET var (DROP=member pos); RENAME num=varnum variable=name len=length; RUN;

Create Index Information We need to build an index line for each file. In order to do this, we access different records and variables from the atr (attribute) and a record from the sortedby&infi (sortedby) file. This presents a challenge as sortedby&infi is not created for an unsorted file.

Create Index Information Within the overall macro, conditionally execute data steps: %IF %SYSFUNC(EXIST(sortedby&infi)) %THEN %DO;... If the file exists then do a data step transforming it... %END; %ELSE %DO;... If it doesn’t exist, then do a data step creating it... %END;

Create Index Information Perform a series of data steps which grab particular variables / records and output a single record file. DATA sorted (KEEP=sorted); SET atr (WHERE=(label1='Data Set Type')); sorted=cvalue2; RUN;...

Create Index Information The single record files for each data set are merged together to create an index file. DATA &headfi; MERGE member memlabel nvars sorted sortvar; RUN; Note that because each header file only has a single record and no common variables, no merge by variable is needed or used in this case.

Report on Designer Data Set(s) The code I’ve shown you glimpses of runs inside a macro, and seven variable level data sets and an index data set have been created. Now, it’s time to create our Excel Workbook, using ODS TAGSETS.EXCELXP and DDE – All without touching your keyboard.

TAGSETS.EXCELXP ODS TAGSETS.EXCELXP FILE=".\file.xml"; ODS TAGSETS.EXCELXP OPTIONS (ABSOLUTE_COLUMN_WIDTH ="32,90,10,10,10,60“ SHEET_INTERVAL="Table“ SHEET_NAME="Index" ); PROC PRINT DATA=index NOOBS; RUN;... ODS TAGSETS.EXCELXP CLOSE; QUIT;

EXCELXP -> DDE -> XLSX Using DDE (Dynamic Data Exchange), we open Excel. Once Excel is open, we then open the XML file created by ODS TAGSETS.EXCELXP, and “save as” an XLSX file. To save space, and avoid confusion, we then delete the XML file. You can also issue other DDE commands to Excel to do things like freeze rows and columns, etc. in the same manner. filename cmds dde 'excel|system';

The Metadata Workbook

CONCLUSION Using the techniques demonstrated in this presentation, you can easily produce metadata workbooks for your project. These techniques can also be used in conjunction with other procedures to produce designer data sets, etc. The possibilities are endless. Could THIS program be improved? Absolutely! We could add formatting to our output workbook with TAGATTR, and streamline the code, etc. Let me know how you make this your own!

Contact Information Your comments and questions are valued and encouraged. Contact the author at: Louise Hadden Code samples are available upon request. SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. Other brand and product names are trademarks of their respective companies.