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.

Slides:



Advertisements
Similar presentations
1/1/ / faculty of Electrical Engineering eindhoven university of technology Managing complex designs Workshop on VLSI Design Using the Interactive Design.
Advertisements

.Graph for Excel Enhancing the Graphics Production Process at the OECD
Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
P5, M1, D1.
Test Case Management and Results Tracking System October 2008 D E L I V E R I N G Q U A L I T Y (Short Version)
This presentation is intended as a detailed WebEx, to bring potential customers to an understanding of Dream Report capabilities. This presentation focuses.
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.
JDK, Jan Pettersen Nytun - HiA 1 The Java Programming Environment: The programmer write source code with a text editor. The programmer write source code.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 Chapter 20 — Creating Web Projects Microsoft Visual Basic.NET, Introduction to Programming.
RESEARCH HUB AT THE UNIVERSITY LIBRARIES PENN STATE UNIVERSITY TOUR OF STATISTICAL PACKAGES.
Adding Automated Functionality to Office Applications.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
PART A Emac Lisp   Emac Lisp is a programming language  Emacs Lisp is a dialect.
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.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
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.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Computer Programming I Hour 1-Getting Started. Word of Day —Chinese proverb A journey of a thousand miles is started by taking the first step. —Aristophanes.
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.
Multi-agent Research Tool (MART) A proposal for MSE project Madhukar Kumar.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
1 Chapter 2 First Java Programs Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
CSC-115 Introduction to Computer Programming
JavaDoc1 JavaDoc DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY July 24, 2006 by Emil Vassev & Joey Paquet revision 1.2 –
BTEC Unit 06 – Lesson 08 Principals of Software Design Mr C Johnston ICT Teacher
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
© 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.
Objected Oriented Programming & Design JAVA Shishir Gupta (704) (704)
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Introduction to Programming with RAPTOR
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
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.
GUI For Computer Architecture May01-05 Team Members: Neil HansenCprE Ben JonesCprE Jon MathewsCprE Sergey SannikovCprE Clients/Advisors: Manimaran Govindarasu.
CS562 Advanced Java and Internet Application Introduction to the Computer Warehouse Web Application. Java Server Pages (JSP) Technology. By Team Alpha.
Polytechnic University of Tirana Faculty of Information Technology Computer Engineering Department A MULTITHREADED SEARCH ENGINE AND TESTING OF MULTITHREADED.
Introduction to OOP CPS235: Introduction.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
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 오혜성, 조형헌, 권윤, 신동준, 이인용.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
BlueJ X ICSE Syllabus. Board Pattern THEORY (100 marks) PRACTICAL (100 marks) PROJECT (50 marks) ASSIGNMENTS (50 marks)
The Reproducible Research Advantage Why + how to make your research more reproducible Presentation for the Center for Open Science June 17, 2015 April.
CST 1101 Problem Solving Using Computers
Advanced Programing practices
Lexical and Syntax Analysis
CSCI-235 Micro-Computer Applications
Functions CIS 40 – Introduction to Programming in Python
Brief Intro to Knitr Package
Introduction to Python
Chapter 1 Introduction(1.1)
Lecture 2: Static Methods Expressions reading: 1.4 – 2.1
Advanced Programing practices
DATABASES WHAT IS A DATABASE?
Programming language translators
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 SAS - and other languages Søren Højsgaard Faculty of Agricultural Sciences Aarhus University Denmark SASforum, May 2009, Copenhagen

Take-home message  Literate programming: Combining text, code and results in one document  Supports text formats:  LaTeX / OpenOffice (OpenDocument Text)  In combination with the ’engines’  SAS, R, S-plus, Maple, Stata, …  Ensures reproducibility of analysis  Great help in ”recalling what I did 2 months ago”  StatWeave does all this – and is free…  This talk: Focus on StatWeave with OpenOffice and SAS/R …

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…

Hello StatWeave World…

What is literate programming  Knuth (1979) coined the term literate programming:  Create software as works of literature:  Embed source code into descriptive text (rather than the opposite which is common practice)  Software should follow flow of thoughts and logic  Should be designed to be readable by humans (and not only by compilers / programs).  Very useful idea in statistics…

Why literate programming?  Reproducible statistical analysis  Research, consulting  Document exactly what has been done  Possible to re-run if data change  Manuals, course notes etc.  Shown output guaranteed to be result of shown code

Some systems for literate programming  Comments inside code  WEB (Knuth 1979) and friends  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 … code in LaTeX and OpenOffice documents

StatWeave  StatWeave created by Russ Lenth, University of Iowa, USA  Available:  StatWeave is in its making, but becomming ”mature” and stable.  Statweave design goals  Support many languages  R, S-plus, SAS, Stata, Maple, …  Support different word processing systems, currently  LaTeX  OpenDocument Text (ODT)  Portability: Usable on all platforms (Written in JAVA)  Extendible:  Add other languages

Under the hood of StatWeave  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:  Generally, source xxx-swv.odt becomes output xxx.odt

Chicken weight data  Set global options (for SAS code)  Inline evaluation of expressions

… chicken weight data

 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…

…code reuse and argument substitution  Costumize display and output (tables) by reusable code chunk

…code reuse and argument substitution

Multi-language example: 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

…Multi-language example: SAS, R and DOS together

 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

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

Odds and ends – Maple  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

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