Worst, but still importable data I’ve ever seen Arthur Tabachneck Insurance Bureau of Canada.

Slides:



Advertisements
Similar presentations
Microsoft Excel 2002 Microsoft Excel is a powerful spreadsheet program that helps you to organize data complete calculations make decisions graph data.
Advertisements

The INFILE Statement Reading files into SAS from an outside source: A Very Useful Tool!
Microsoft Excel. Click on “Start,” then “Microsoft Office Excel.”
Using Microsoft ® Excel Formulas and Functions Start Microsoft ® Excel. Type data into cells as shown.
WORKING SMART Crystal M. Thomas Henrico County DSS (804) POSSESS Central Region Member October 31, 2007.
1 After completing this lesson, you will be able to: Create a workbook. Understand Microsoft Excel window elements. Select cells. Enter text, numbers,
Templates and Styles Excel Advanced. Templates are pre- designed and formatted spreadsheets –They provide consistency of layout/structure –They.
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.
Understanding Microsoft Excel
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.
Enough really good SAS ® tips to fill a book Arthur Tabachneck, President and CEO, myqna.org.
Assignment 3 Excel Tutorial IS for Management2 Content –Accurate –Relevant –Complete –Concise Time –Timely –Frequent (enough) Form –Easy to read –Appropriately.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
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.
Lesson 1 – Microsoft Excel The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
Microsoft Excel By: Dr. K.V. Vishwanath Professor, Dept. of C.S.E,
 Starting Excel 2003  Using Help  Workbook Management  Cursor Management  Manipulating Data  Using Formulae and Functions  Formatting Spreadsheet.
An Animated Guide©: Sending SAS files to Excel Concentrating on a D.D.E. Macro.
Learning Objectives What is a spreadsheet and what is the difference between a spreadsheet and a worksheet? Start Excel, open an existing spreadsheet,
Jack Working with Excel - Usage of Dynamic Data Exchange in PMS studies.
1 Performing Spreadsheet What-If Analysis Applications of Spreadsheets.
Excel Ch 6 Review.
XP New Perspectives on Integrating Microsoft Office XP Tutorial 2 1 Integrating Microsoft Office XP Tutorial 2 – Integrating Word, Excel, and Access.
Introduction to Excel What Can I Do with a Spreadsheet?
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Lesson 1 Introduction.
Key Applications Module Lesson 21 — Access Essentials
Lesson 2 Topic - Reading in data Chapter 2 (Little SAS Book)
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.
XP New Perspectives on Microsoft Office Excel 2003, Second Edition- Tutorial 1 1 Microsoft Office Excel 2003 Using Excel To Manage Data.
Melanie Peasnall. MS Word Microsoft Word is a word processing program that allows you to make text files. This can be anything from a note to a novel.
Lesson 1 – Microsoft Excel * The goal of this lesson is for students to successfully explore and describe the Excel window and to create a new worksheet.
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.
Microsoft Excel. Excel specializes in creating and designing spreadsheets, or worksheets Worksheet – area to insert data Workbook – a set of worksheets.
Spreadsheets 101 What is Excel?. Objectives 1. Identify the parts of the Excel Screen 2. Identify the functions of a spreadsheet 3. Identify how spreadsheets.
YET ANOTHER TIPS, TRICKS, TRAPS, TECHNIQUES PRESENTATION: A Random Selection of What I Learned From 15+ Years of SAS Programming John Pirnat Kaiser Permanente.
1 Statistical Software Programming. STAT 6360 –Statistical Software Programming Data Input in SAS Many ways to get your data into SAS: –Through data entry.
TASS Meeting Setting GuessingRows when Importing Excel Files September 19th, 2008 Setting GuessingRows when importing Excel Files Dr. Arthur Tabachneck,
Introduction to Spreadsheets and Microsoft Excel FSE 200.
TASS Meeting Using Multiple DOW Loops September 25th, 2009 Using Multiple DOW Loops Dr. Arthur Tabachneck Director, Data Management Idea stolen from a.
Lesson 2 Topic - Reading in data Programs 1 and 2 in course notes –Chapter 2 (Little SAS Book)
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.
APA Cover Page Dr. Gustafson. What is a Cover Page? APA Manual 6 th Edition – See Manuscript Elements A cover page is the first page of your.
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.
Day 1: MS Excel for Beginners Aniko Balogh CEU Computer & Statistics Center
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
Computer/LMS Access To log onto one of these computers: Enter your Username, for example: 2014BNS099 followed So a complete login.
SAS ® Global Forum 2014 March Washington, DC Arthur Tabachneck Thornhill, ON Canada Tom Abernathy New York, NY Matt Kastin Penn Valley, PA.
Build your Metadata with PROC CONTENTS and ODS OUTPUT Louise S. Hadden Abt Associates Inc.
TASS Meeting Quickly Finding Project Code March 13th, 2009 A way to quickly find all of your project code Dr. Arthur Tabachneck Director, Data Management.
Excel Tutorial 8 Developing an Excel Application
Spreadsheet Manager Training Module
Microsoft Excel Chapter 3.
INTRODUCTION TO SPREADSHEET APPLICATIONS
Sowmya Devaraja August 25, 2016
After completing this lesson, you will be able to:
Chapter 2: Getting Data into SAS
Project Management Skills.
Microsoft Excel 101.
Microsoft Excel All editions of Microsoft office.
Project Management Skills
Microsoft Excel 2007 – Level 2
Integration - an introduction
IMPORTING DATA WITH DDE (Dynamic Data Exchange) Or Proc Import?
Dr. Arthur Tabachneck Director, Data Management
a useful SAS 9.2 feature I wasn’t aware of *
Presentation transcript:

worst, but still importable data I’ve ever seen Arthur Tabachneck Insurance Bureau of Canada

Coder’s Corner April 12, 2010 Forum SAS suppose you had the following excel file: format: text format: as shown format: m/d/yyyy format: d/m/yyyy format: text format: d-mon format: text

Coder’s Corner April 12, 2010 Forum SAS how the file got so bad: members of a secretarial pool were asked to enter the data, in Excel, while they were covering the front desk they (four different secretaries), obviously, weren’t given sufficient instructions their task was simply to enter some data, which happened to include a date

Coder’s Corner April 12, 2010 Forum SAS proc import can only be used if: you license SAS/Access Interface to PC File Formats and at least half of the relevant rows (based on your system’s and SAS guessingrows settings) are formatted as dates or you manually edit the spreadsheet and/or change your guessing rows settings so that condition #2 holds 1 2 3

Coder’s Corner April 12, 2010 Forum SAS If proc import can be used, three steps are necessary step 1: use mixed=no

Coder’s Corner April 12, 2010 Forum SAS which will import date formatted cells and assign missing values to the other cells

Coder’s Corner April 12, 2010 Forum SAS step 2: use mixed=yes which will import all cells as text

Coder’s Corner April 12, 2010 Forum SAS step 3 merge the two files and use inputn to read missing dates data want (drop=bdate); set inputa; set inputb (rename=(date=bdate)); if missing(date) then do; options datestyle=dmy; date=inputn(bdate, ‘anydtdte’, 20); end; if missing(date) then do; date=inputn(catt(scan(bdate,2,’-’), scan(bdate,1,’-’), scan(bdate,3,’-’)), ‘anydtdte’, 20); end; run;

Coder’s Corner April 12, 2010 Forum SAS resulting in the following file

Coder’s Corner April 12, 2010 Forum SAS however, if proc import can’t be used or if you simply want a better solution

Coder’s Corner April 12, 2010 Forum SAS you can do it with DDE options noxsync noxwait xmin; filename sas2xl dde 'excel|system'; step 1: set desired options and filename

Coder’s Corner April 12, 2010 Forum SAS Step 2: Open Excel data _null_; length fid rc start stop time 8; fid=fopen('sas2xl','s'); if (fid le 0) then do; rc=system('start excel'); start=datetime(); stop=start+10; do while (fid le 0); fid=fopen('sas2xl','s'); time=datetime(); if (time ge stop) then fid=1; end; end; rc=fclose(fid); run;

Coder’s Corner April 12, 2010 Forum SAS Step 3: Open workbook and insert old-style macro sheet data _null_; file sas2xl; put '[open("c:\worst data.xls")]'; run; data _null_; file sas2xl; put '[workbook.next()]'; put '[workbook.insert(3)]'; run; filename xlmacro dde 'excel|macro1!r1c1:r99c1‘ notab lrecl=200;

Coder’s Corner April 12, 2010 Forum SAS Step 4: Create and run Excel macro data _null_; file xlmacro; put '=set.name("Tag",!$b$1)'; put '=formula("<>",Tag)'; put '=set.name("OldValue",!$c$1)'; put '=set.name("NewValue",!$b$2)'; put '=for.cell("CurrentCell",sheet1!$a$2:$a$99,true)'; put '=formula(get.cell(5,CurrentCell),OldValue)'; put '=formula("=concatenate(Tag,OldValue)",NewValue)'; put '=formula(NewValue, CurrentCell)'; put '=next()'; put '=halt(true)'; put '!dde_flush'; file sas2xl; put '[run("macro1!r1c1")]'; put '[workbook.activate("sheet1")]'; put ‘[error(false)]’; put '[save.as(“c:\DateTest",6)]'; put '[quit()]'; run;

Coder’s Corner April 12, 2010 Forum SAS Step 5: Import the data data want (keep=date); infile "c:\DateTest.csv" dsd dlm="," lrecl=32768 firstobs=2; informat rawdate $20.; input rawdate; format date date9.; rawdate=substr(rawdate,3); if anyalpha(rawdate) then do; options datestyle=dmy; date=inputn (rawdate, 'anydtdte', 20 ); if missing(Date) then do; date=inputn(catt(scan(rawdate,2,'-'),scan(rawdate,1,'-'), scan(rawdate,3,'-')),'anydtdte', 20) ; end; end; else Date=rawdate-21916; run;

Coder’s Corner April 12, 2010 Forum SAS and obtain the desired result regardless of your system’s guessing rows setting or how your data is arranged

Coder’s Corner April 12, 2010 Forum SAS Author Contact Information Your comments and questions are valued and encouraged. Contact the author: Dr. Arthur Tabachneck Director, Data Management Insurance Bureau of Canada Toronto, Ontario L3T 5K9 Canada atabachneck at ibc dot ca or art297 at netscape dot net

Coder’s Corner April 12, 2010 Forum SAS Microsoft Corporation. Function Reference Microsoft EXCEL Spreadsheet with Business Graphics and Database: Version 4.0 for Apple® Macintosh® Series or Windows™ Series. Document AB , Vyverman, K. Excel Exposed: Using Dynamic Data Exchange to Extract Metadata from MS Excel Workbooks, SESUG 17, 2003, paper TU15, St. Pete Beach, FL Vyverman, K. Re: How to flag special formatting from Excel in a SAS dataset. SAS-L Post, 2002, Vyverman, K. Re: MS Excel column widths. SAS-L Post, 2002, Vyverman, K. Using Dynamic Data Exchange to Export Your SAS Data to MS Excel – Against All ODS, Part I, SUGI 26, 2001, paper , Long Beach, CA. Key References