Next Presentation: Presenter: Arthur Tabachneck Copy and Paste from Word or Excel to SAS Art holds a PhD from Michigan State University, has been a SAS.

Slides:



Advertisements
Similar presentations
The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
Advertisements

Slide C.1 SAS MathematicalMarketing Appendix C: SAS Software Uses of SAS  CRM  datamining  data warehousing  linear programming  forecasting  econometrics.
WORKING SMART Crystal M. Thomas Henrico County DSS (804) POSSESS Central Region Member October 31, 2007.
Worst, but still importable data I’ve ever seen Arthur Tabachneck Insurance Bureau of Canada.
With Microsoft Access 2010© 2011 Pearson Education, Inc. Publishing as Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access.
Working Smarter, Not Harder with DDE: Did I Really Spend All That Time Just Formatting My Report? Bobby Kidd Vice President Senior Statistical Portfolio.
Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John.
Beginning Data Manipulation HRP Topic 4 Oct 19 th 2011.
Enough really good SAS ® tips to fill a book Arthur Tabachneck, President and CEO, myqna.org.
Computers Are Your Future © 2008Prentice-Hall, Inc.
Understanding SAS Data Step Processing Alan C. Elliott stattutorials.com.
Creating SAS® Data Sets
Introduction to VBA. This is not Introduction to Excel We’re going to assume you have a basic level of familiarity with Excel If you don’t, or you need.
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.
Advanced Excel for Finance Professionals A self study material from South Asian Management Technologies Foundation.
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-
Hello SAS 9.4: What's New? ChrIs Hemedinger, SAS.
Chapter 20 Creating Multiple Observations from a Single Record Objectives Create multiple observations from a single record containing repeating blocks.
©Spring 2012 Imelda Go, John Grego, Jennifer Lasecki and the University of South Carolina Chapter 17 supplement: Review of Formatting Data STAT 541.
Report Management Using the ODS DOCUMENT Destination and Report Metadata Brit Harvey February 2010.
Using Advanced INPUT Techniques Peter Cosette Dave Hall Amy Dunn-Ruiz Eric Lyon.
Introduction to HTML Reporting with SAS Welcome to HTML reporting with SAS Sam Gordji, Weir 107.
SAS Efficiency Techniques and Methods By Kelley Weston Sr. Statistical Programmer Quintiles.
Computers Are Your Future © 2005 Prentice-Hall, Inc.
Get up to speed with the 2007 Office system Answers to critical questions Now it’s time to look beyond the Ribbon and see what else is new. The Microsoft.
EPIB 698C Lecture 2 Notes Instructor: Raul Cruz 2/14/11 1.
I OWA S TATE U NIVERSITY Department of Animal Science Getting Your Data Into SAS (Chapter 2 in the Little SAS Book) Animal Science 500 Lecture No. 3 September.
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
Software Development Process.  You should already know that any computer system is made up of hardware and software.  The term hardware is fairly easy.
TASS Meeting Copy and Paste from Excel to SAS September 19th, 2008 Copy and Paste from Excel to SAS Dr. Arthur Tabachneck, Director Data Management with.
ISU Basic SAS commands Laboratory No. 1 Computer Techniques for Biological Research Animal Science 500 Ken Stalder, Professor Department of Animal Science.
1 Data Manipulation (with SQL) HRP223 – 2010 October 13, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Creating and Using Custom Formats for Data Manipulation and Summarization Presented by John Schmitz, Ph.D. Schmitz Analytic Solutions, LLC Certified Advanced.
Microsoft Excel – Pivot Tables Introduction to Microsoft Excel Pivot tables Please login to the computers and launch Microsoft Excel. Rob Jones Room WG43.
Here’s another problem (see section 2.13 on page 54). A file contains two different types of records (say A’s and B’s) and we only want to read in the.
© 2014 by McGraw-Hill Education. This proprietary material solely for authorized instructor use. Not authorized for sale or distribution in any manner.
1 Statistical Software Programming. STAT 6360 –Statistical Software Programming Data Input in SAS Many ways to get your data into SAS: –Through data entry.
Chapter 1: Overview of SAS System Basic Concepts of SAS System.
Integrate, check and share documents Module 3.3. Integrate, check and share documents Module 3.3.
Introduction to BASIC Programming Ken R. Hall, Ph.D. Ken R. Hall Consultants Portland, Oregon.
FIRST COURSE Integration Tutorial 2 Integrating Word, Excel, and Access.
TASS Meeting Setting GuessingRows when Importing Excel Files September 19th, 2008 Setting GuessingRows when importing Excel Files Dr. Arthur Tabachneck,
FIRST COURSE PowerPoint Tutorial 4 Integrating PowerPoint with Other Programs and Collaborating with Workgroups.
FORMAT statements can be used to change the look of your output –if FORMAT is in the DATA step, then the formats are permanent and stored with the dataset.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
Compare and Contrast : Blackboard & a Personal Web Page www3.ltu.edu/~s_schneider/howto/faculty.htm You’ll find this presentation (and another) here :
CC07 PhUSE 2011 Seven Sharp tips for Clinical Programmers David Garbutt Rohit Banga BIOP AG.
Lesson 2 Topic - Reading in data Programs 1 and 2 in course notes –Chapter 2 (Little SAS Book)
1 Data Manipulation (with SQL) HRP223 – 2009 October 12, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
TASS Meeting using inputn to re-format data September 25 th, 2009 using inputn to re-format data Dr. Arthur Tabachneck Director, Data Management Note:
Computers Are Your Future Tenth Edition Spotlight 5: Microsoft Office Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall1.
Use SAS to Automate Hospital Reports generation Cardiac Service BC Stats Team, PHSA Tina Yang.
Copyright 2009 The Little Engine That Could: Using EXCEL LIBNAME Engine Options to Enhance Data Transfers between SAS® and Microsoft® Excel Files William.
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
SAS ® Global Forum 2014 March Washington, DC Arthur Tabachneck Thornhill, ON Canada Tom Abernathy New York, NY Matt Kastin Penn Valley, PA.
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.
Copyright 2007, Paradigm Publishing Inc. EXCEL 2007 Chapter 8 BACKNEXTEND 8-1 LINKS TO OBJECTIVES Import data from Access, a Web site, or a CSV text file.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 5 & 6 By Ravi Mandal.
Hints and Tips SAUSAG Q SORTING – NOUNIQUEKEY The NOUNIQUEKEY option on PROC SORT is a useful way in 9.3 to easily retain only those records with.
Chapter 8 Using Document Collaboration, Integration, and Charting Tools Microsoft Word 2013.
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 3 & 4 By Tasha Chapman, Oregon Health Authority.
SAS ® Global Forum 2014 March Washington, DC Arthur Tabachneck Thornhill, ON Canada Tom Abernathy New York, NY Matt Kastin Penn Valley, PA.
Downloading and Preparing a StudentVoice File for SPSS
Introduction to SAS®.
Chapter 2: Getting Data into SAS
Computers Are Your Future
Microsoft Excel 2007 – Level 2
Increase Your Productivity by Doing Less
a useful SAS 9.2 feature I wasn’t aware of *
A Better Way to Flip (Transpose) a SAS® Dataset
Presentation transcript:

Next Presentation: Presenter: Arthur Tabachneck Copy and Paste from Word or Excel to SAS Art holds a PhD from Michigan State University, has been a SAS user since 1974, is president of the Toronto Area SAS Society and has received such recognitions as the SAS Customer Value Award (2009), SAS-L Hall of Fame (2011), SAS Circle of Excellence (2012) and, in 2013, was recognized as being the first SAS Discussion Forum participant to be awarded more than 10,000 points

Arthur Tabachneck Thornhill, ON Canada Matt Kastin Penn Valley, PA

Suppose you have data in an Excel workbook

or a table in a Word Document

and you had a one-time need to import the data into a SAS dataset

you have SAS/Access interface to PC files you don't have a 32/64 bit compatibility issue and then you could do it using PROC IMPORT: proc import out= work.want datafile= "c:\orsales.xlsx" dbms=xlsx replace; run; if the data are in an Excel workbook and your SAS version supports Excel 2010 and

your SAS version doesn't support Excel 2010 you don't have SAS/Access Interface to PC files but, what if: you keep running into 32/64 bit compatibility issues and/or you need more control over formats, informats or variable names and/or the table is in something other than Excel (e.g., Microsoft Word or a web page) and/or

a simple solution? a datastep that uses the clipboard access method gives you total control over all formats and informats

if only if it worked that way, but.. you can't include notab and lrecl options with the method won't work if any records have more than 256 characters will fail if there are any missing cells in the data

but the Clipboard Access Method will work as follows:

How it works Open the workbook in Excel 1 Press Ctrl-A, then press Ctrl-C 2 selects all of the workbook's cells copies the selected cells to your computer's clipboard

then Run a datastep in SAS 3 filename clippy clipbrd; data orsales_short; attrib Quarter label='Quarter' length=8 informat = yyq6. format=yyq6. Product_Group label='Group' length=$ 25 informat= $25. format=$25. Quantity label='Number of Items' length=8 informat=6. format= 6. Profit label='Profit in USD' length=8 informat=12. format=12.2 Field163 label='Short' length=$ 163 informat=$163. format= $163.; infile clippy missover firstobs=2; input; _infile_ = transtrn( trim( _infile_ ), ' ', '09'x ); quarter = input( scan( _infile_, 1, '09'x,'m'), yyq6. ) ; product_group = scan( _infile_, 2, '09'x,'m') ; quantity = input( scan( _infile_, 3, '09'x,'m'), 6. ) ; profit = input( scan( _infile_, 4, '09'x,'m'), 12. ) ; field163 = scan( _infile_, 5, '09'x,'m') ; run; filename clippy clear;

Open the Word file 1 Click on the table move handle (i.e., ) 2 Press Ctrl-C 3 Works for tables copied from either Word or Excel selects all of the table's cells copies the selected cells to your computer's clipboard

Works for tables copied from either Word or Excel then just run the same SAS code

won't work if any record contains more than 256 characters Works for tables copied from either Word or Excel one alternative for longer records, but only for tables copied from Excel and only on systems that can use DDE: filename clippy dde 'clipboard'; data orsales; infile clippy lrecl=400 dsd notab missover dlm='09'x firstobs=2; informat long_field $char327.; informat quarter yyq6.; format quarter YYQ6.; informat product_group $char24.; input quarter product_group quantity profit long_field; run; filename clippy clear;

data want; attrib _inline_ length = $ Quarter label = 'Quarter' length = 8 informat = yyq6. format = yyq6. Product_Group label = 'Product Group' length = $ 24 informat = $24. format = $24. Quantity label = 'Number of Items' length = 8 informat = 6. format = 6. Profit label = 'Profit in USD' length = 8 informat = 12. format = 12.2 field163 label = 'Short Field' length = $ 163 informat = $163. format = $163. ; keep quarter product_group quantity profit field163; rc = filename( 'clippy', ' ', 'clipbrd' ); if ( rc ne 0 ) then link err; fid = fopen( 'clippy', 's', 32767, 'V' ); if ( fid eq 0 ) then link err; A method that works with both Word and Excel, on all systems, and for records with more than 256 characters do _n_=1 by 1 while( fread( fid ) = 0 ); rc = fget( fid, _inline_, ); _inline_ = transtrn( trim( _inline_ ), ' ', '09'x ); if _n_=1 then continue; quarter = input( scan( _inline_, 1, '09'x ), yyq6.,'m') ; product_group = scan( _inline_, 2, '09'x,'m' ) ; quantity= input( scan( _inline_, 3, '09'x ), 6.,'m' ) ; profit = input( scan( _inline_, 4, '09'x ), 12.,'m' ) ; field163= scan( _inline_, 5, '09'x,'m' ) ; output; end; rc = fclose( fid ); rc = filename( 'clippy' ); stop; err: do; m = sysmsg(); put m; stop; end; run;

three methods were presented for copying and pasting from Excel workbooks and Word tables only one method, the Clipboard Access Method using functions, worked in all cases: Summary with both Excel and Word with record lengths greater than 256 characters without being operating system specific with various combinations of missing data

Your comments and questions are valued and encouraged Contact the Authors Arthur Tabachneck, Ph.D. Vice President, The Catalog Thornhill, ON Matt Kastin I-Behavior, Inc. Penn Valley, PA