A A R H U S U N I V E R S I T E T Faculty of Agricultural Sciences Literate programming with multiple languages Russel V. Lenth Department of Statistics.

Slides:



Advertisements
Similar presentations
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Advertisements

HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Key-word Driven Automation Framework Shiva Kumar Soumya Dalvi May 25, 2007.
A A R H U S U N I V E R S I T E T Faculty of Agricultural Sciences Literate programming with SAS - and other languages Søren Højsgaard Faculty of Agricultural.
John Porter Why this presentation? The forms data take for analysis are often different than the forms data take for archival storage Spreadsheets are.
Java Programming, 3e Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Ann Arbor ASA ‘Up and Running’ Series: SPSS Prepared by volunteers of the Ann Arbor Chapter of the American Statistical Association, in cooperation with.
July 11 th, 2005 Software Engineering with Reusable Components RiSE’s Seminars Sametinger’s book :: Chapters 16, 17 and 18 Fred Durão.
Publishing Workflow for InDesign Import/Export of XML
Program Design and Development
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
RESEARCH HUB AT THE UNIVERSITY LIBRARIES PENN STATE UNIVERSITY TOUR OF STATISTICAL PACKAGES.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 16 Slide 1 User interface design.
ECE 265 – LECTURE 9 PROGRAM DESIGN 8/12/ ECE265.
PART A Emac Lisp   Emac Lisp is a programming language  Emacs Lisp is a dialect.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
MS Access: Database Concepts Instructor: Vicki Weidler.
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMING PRACTICES API documentation.
CEDROM-SNi’s DITA- based Project From Analysis to Delivery By France Baril Documentation Architect.
MS Access Advanced Instructor: Vicki Weidler Assistant:
1 Integrated Development Environment Building Your First Project (A Step-By-Step Approach)
A First Program Using C#
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
Summary Data Modeling SDLC What is Data Modeling Application Audience and Services Entities Attributes Relationships Entity Relationship Diagrams Conceptual,Logical.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Existential Graphs Software Dr. Russell Herman Department of Mathematics and Statistics University of North Carolina at Wilmington August 2003.
JavaDoc1 JavaDoc DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY July 24, 2006 by Emil Vassev & Joey Paquet revision 1.2 –
Report Management Using the ODS DOCUMENT Destination and Report Metadata Brit Harvey February 2010.
BTEC Unit 06 – Lesson 08 Principals of Software Design Mr C Johnston ICT Teacher
Khoros Yongqun He Dept. of Computer Science, Virginia Tech.
© 2001 Business & Information Systems 2/e1 Chapter 8 Personal Productivity and Problem Solving.
Lead Black Slide Powered by DeSiaMore1. 2 Chapter 8 Personal Productivity and Problem Solving.
Transferring VMS SAS/SPSS Data to UNIX Jeff Hayes Social Science Computing Co-op February 26, 1999.
Guide to Linux Installation and Administration, 2e1 Chapter 7 The Role of the System Administrator.
By Ian Jackman Davit Stepanyan.  User executed untested code.  The order in which statements were meant to be executed are different than the order.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
1 ADVANCED MICROSOFT POWERPOINT Lesson 9 – Importing and Exporting Information Microsoft Office 2003: Advanced.
Convert PDF files to PowerPoint slides Extract specific PDF pages to PowerPoint - Support to convert encrypted PDF files - Convert PDF to PowerPoint 2003/2007/2010.
BOĞAZİÇİ UNIVERSITY DEPARTMENT OF MANAGEMENT INFORMATION SYSTEMS MATLAB AS A DATA MINING ENVIRONMENT.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Java Programming, 2E Introductory Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Structural Design Software TYLER HUTCHISON. Requirements  Develop an interface to generate a text file.  The text file is then passed to one of five.
Introduction into JavaScript Java 1 JavaScript JavaScript programs run from within an HTML document The statements that make up a program in an HTML.
Copyright © 2010, SAS Institute Inc. All rights reserved. SAS ® Using the SAS Grid.
Polytechnic University of Tirana Faculty of Information Technology Computer Engineering Department A MULTITHREADED SEARCH ENGINE AND TESTING OF MULTITHREADED.
KEEP THIS TEXT BOX this slide includes some ESRI fonts. when you save this presentation, use File > Save As > Tools (upper right) > Save Options > Embed.
Introduction to OOP CPS235: Introduction.
Chapter – 8 Software Tools.
Introduction to Literate Programming in Matlab 2WN50 – Week programming-in-matlab.pptx?dl=0.
1 EPIB 698C Lecture 1 Instructor: Raul Cruz-Cano
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Chapter 04 Semantic Web Application Architecture 23 November 2015 A Team 오혜성, 조형헌, 권윤, 신동준, 이인용.
Visual Programming Borland Delphi. Developing Applications Borland Delphi is an object-oriented, visual programming environment to develop 32-bit applications.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
1 Programming and problem solving in C, Maxima, and Excel.
The Reproducible Research Advantage Why + how to make your research more reproducible Presentation for the Center for Open Science June 17, 2015 April.
1 Team Skill 3 Defining the System Part 1: Use Case Modeling Noureddine Abbadeni Al-Ain University of Science and Technology College of Engineering and.
Advanced Programing practices
CSCI-235 Micro-Computer Applications
Functions CIS 40 – Introduction to Programming in Python
Brief Intro to Knitr Package
Chapter 7: Macros in SAS Macros provide for more flexible programming in SAS Macros make SAS more “object-oriented”, like R Not a strong suit of text ©
Chapter 1 Introduction(1.1)
Advanced Programing practices
DATABASES WHAT IS A DATABASE?
Presentation transcript:

A A R H U S U N I V E R S I T E T Faculty of Agricultural Sciences Literate programming with multiple languages Russel V. Lenth Department of Statistics & Actuarial Science, The University of Iowa, USA Søren Højsgaard Faculty of Agricultural Sciences Aarhus University Denmark DSC 2009, July 2009, Copenhagen, Denmark

Take-home message  Literate programming: Combining text, code and results in one document  StatWeave does this  Supports text formats:  LaTeX / OpenOffice (OpenDocument Text)  In combination with one or several of the ’engines’  SAS, R, S-plus, Maple, Stata, Matlab, shell…  StatWeave is  ”Sweave for generalized values of LaTeX and S”  Jave based and hence portable  A great help in creating reproducible statistical analyses  Extensible: Add languages

Overview – Combining code, documentation and results Source document  Writing  SAS statements  More writing  R statements  Even more writing  More SAS statements  More writing… Final document  Writing  SAS statements  SAS output  SAS graphics  More writing  R statements  R output  Even more writing  SAS statements  SAS output  More writing…

Example: R + LaTeX

Example: SAS + OpenDocument Text

What is literate programming  Term coined by Knuth (1979):  Create software as works of literature:  Embed source code into descriptive text (rather than the opposite)  Software should follow flow of thoughts and logic  Should be designed to be readable by humans (and not only by compilers / programs).  Some systems for literate programming (in statistics)  Sweave (Lesich 2002)  R code in LaTeX documents  odfWeave (Kuhn and Coulter 2007)  R code in OpenOffice documents  SASweave (Lenth and Højsgaard 2007)  SAS / R code in LaTeX documents  StatWeave  SAS / R / maple / S-plus / Stata / Matlab / shell… code in LaTeX and OpenOffice documents

Why literate programming?  Reproducible statistical analysis  Research, consulting  Document exactly what has been done  Possible to re-run if data change  Maintain one document only (at least in principle)  Manuals, course notes etc.  Shown output guaranteed to be result of shown code

StatWeave  StatWeave created by Russ Lenth, University of Iowa, USA  Available:  StatWeave is in its making, but becomming ”mature” and stable.  Source file is regular text document but with code chunks added (with special tags)  Two basic operations  Weaving: Process source file into single document with code listings, output listings, graphs…  Tangling: Extract code from source file to run later  Weaving is useful for reproducible statistical analysis

Running StatWeave  Command-line interface: statweave SAS-HelloWorld-swv.odt statweave --tangle SAS-HelloWorld-swv.odt statweave --keepall SAS-HelloWorld-swv.odt  Graphical User Interface:

Example: SAS + ODT  Set global options (for SAS code)  Inline evaluation of expressions

Example: SAS + ODT

 Output can be saved for later use  - and display

Code reuse and argument substitution  Save code chunks for later execution  Pass arguments to code chunks  Simplest case: Not unlike a macro…

Example: SAS + ODT - code reuse and argument substitution  Costumize display and output (tables) by reusable code chunk

Example: SAS + ODT - code reuse and argument substitution

Example: Multiple languages - SAS, R and DOS together  Can use different engines in the same source file  Use SAS when appropriate; use R when appropriate; use Maple when appropriate…  Weaving:  SAS/R/XX chunks assembled into separate code files.  Code files are processed in order of first appearence in the source file

Example: Multiple languages

 Synchronization issue: SAS chunk depends on data from R chunk which depends on data from SAS chunk….  Solution: The restart option will restart the engines

Example: Maple + LaTeX

Example: Maple + ODT  Differentiate y= sin(x) x x x  Output is ugly, but it reads:

Odds and ends – calling the shell  Want to list all StatWeave / Open office source files: *-swv.odt

Code chunks are processed as a whole  Code chunks are processed as a ”unit” so in general one can not split a call to proc xxxx over several chunks:  Thus the following is illegal

… one exception in SAS: IML

Summary  Reproducible statistical analyses  Integrate text, code and results in one document  Several text formats  Several languages  This talk (and the examples) available at  All credit is due to Russ Lenth, the creator of StatWeave. Thanks!!!!