1 Paper 121-2013 Reading Data from Microsoft®Word Documents: It’s Easier Than You ThinkJohn E. Bentley, Wells Fargo Bank ABSTRACT SAS®provides the capability of reading data from a Microsoft Word document, and it's easy once you know how to do it. Using the FILENAME statement with the DDE engine makes it unnecessary to export to Excel or work with an XML map. This paper goes through the steps of having SAS read a Word document and shares a an example that demonstrates how easy it is and how you can leverage the capability. All levels of SAS users may find this paper useful. INTRODUCTION Much has been presented and published at SAS Conferences about SAS and Microsoft Office working together but most focus on SAS and Excel. Vince DelGabbo is especially prolific as an author and presenter when it comes to SAS and MS Office. His papers extensively cover using XML and ODS techniques, and other authors cover OLE DB, DDE, Visual Basic for Applications, the Excel LIBNAME Engine, and the SAS Add-In for Microsoft Office. This paper looks at a different approach, one that the author found covered by only one other Conference paper back in 1998. The basic techniques of using SAS to read from (or write to) Word are to assign Bookmarks to specific locations in the document and then use FILENAME statements with the DDE device-type key to point to those bookmarks. With this done, the bookmark can be accessed as a data set with a single-variable or a tab-delimited text file. The focus of this paper is reading tables in a Word document and then using the data from those tables to generate SAS SQL code. WORD BOOKMARKS Bookmarks are a great way to quickly navigate large complex documents. They allow quick movement to specific sections of the document or items of information and do not affect the readability or printability of the document. In this author’s experience they are very underutilized. Although they are intended to be navigational tools, they’re also the key to letting SAS easily read from Word. Adding a bookmark is basically the same in Word 2003, 2007, and 2010. First move the cursor to where you want the bookmark to be or highlight the section of text or table that you want bookmarked. Then select the ‘Insert’tab on the tool Ribbon. On the Insert Ribbon towards the middle is the ‘Links’group. Click on ‘Bookmark’and the bookmark dialog box appears. Display 1. Word Bookmark Dialog Box Foundations and FundamentalsSAS Global Forum 2013
has intentionally blurred sections.
Sign up to view the full version.