Writing Maintainable Code with ‘Style’ Allan Page Senior Marketing Analyst Canadian Tire Bank.

Slides:



Advertisements
Similar presentations
Copyright © 2006, SAS Institute Inc. All rights reserved. Think FAST! Use Memory Tables (Hashing) for Faster Merging Gregg P. Snell Data Savant Consulting.
Advertisements

Examples from SAS Functions by Example Ron Cody
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
2440: 211 Interactive Web Programming JavaScript Fundamentals.
Lecture-5 Though SQL is the natural language of the DBA, it suffers from various inherent disadvantages, when used as a conventional programming language.
Introduction to Computers and Programming Lecture 9: For Loops New York University.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction.
Chapter 2: Introduction to C++.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Copyright © 2006, SAS Institute Inc. All rights reserved. Shortcuts- what you may not know that can save you time! Elizabeth Ceranowski SAS Student Programs.
“SAS macros are just text substitution!” “ARRRRGGHHH!!!”
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
Chapter 4 Code Editor Goals and Objectives Program more efficiently? How can you speed up your development process? Do you want to learn useful shortcuts.
Javascript and the Web Whys and Hows of Javascript.
Copyright © 2008, SAS Institute Inc. All rights reserved. SAS ® Macros: Top-Five Questions (and Answers!) Kim Wilson –Technical Support Analyst SAS Institute.
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
University of Toronto at Scarborough © Andria Hunter, Kersti Wain-Bantin CSCA01 VBA-3 1 Lecture Outline Variable Scope Calling another subprogram Programming.
Programming Style and Documentation Objective(s) F To become familiar with Java Style and Documentation Guidelines.
A First Program CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington Credits: a significant part of.
An Animated Guide©: Sending SAS files to Excel Concentrating on a D.D.E. Macro.
Introduction to Java Thanks to Dan Lunney (SHS). Java Basics File names The “main” method Output to screen Escape Sequence – Special Characters format()
SAS Macro: Some Tips for Debugging Stat St. Paul’s Hospital April 2, 2007.
INTRODUCTION TO SAS MACRO PROCESSING James R. Bence, Ph.D., Co-Director Quantitative Fisheries Center Professor Department of Fisheries and Wildlife March.
1 PhUSE 2011 Missing Values in SAS Magnus Mengelbier Director.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Java Syntax and Style JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin,
Macro Overview Mihaela Simion. Macro Facility Overview Definition : The SAS Macro Facility is a tool within base SAS software that contains the essential.
Copyright © 2005, SAS Institute Inc. All rights reserved. Effective Use of SAS/GRAPH® Stored Processes Pat Berryman Senior Software Manager Data Visualization.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
1 Lab 2 and Merging Data (with SQL) HRP223 – 2009 October 19, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning:
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Recognizing PL/SQL Lexical Units. 2 home back first prev next last What Will I Learn? List and define the different types of lexical units available in.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Strings, output, quotes and comments
Introduction to SAS Macros Center for Statistical Consulting Short Course April 15, 2004.
BMTRY 789 Lecture 11: Debugging Readings – Chapter 10 (3 rd Ed) from “The Little SAS Book” Lab Problems – None Homework Due – None Final Project Presentations.
A SAS User's Guide to Storage Management Allan Page Senior Marketing Analyst Canadian Tire Financial Services.
CMSC 104, Lecture 111 Introduction to C Topics l Compilation l Using the gcc Compiler l The Anatomy of a C Program l 104 C Programming Standards and Indentation.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Inventory Application.
YET ANOTHER TIPS, TRICKS, TRAPS, TECHNIQUES PRESENTATION: A Random Selection of What I Learned From 15+ Years of SAS Programming John Pirnat Kaiser Permanente.
Summer SAS Workshop Lecture 3. Summer SAS Workshop Website
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessor Midterm Review Lecture 7 Feb 17, 2004.
Chapter 7: Macros in SAS  Macros provide for more flexible programming in SAS  Macros make SAS more “object-oriented”, like R 1 © Fall 2011 John Grego.
Python Let’s get started!.
Copyright © 2004, SAS Institute Inc. All rights reserved. SASHELP Datasets A real life example Barb Crowther SAS Consultant October 22, 2004.
CS12230 Introduction to Programming Lecture 6-2 –Errors and Exceptions 1.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
MIPS assembly syntax Home Assignment 3 Assigned. Deadline 2016 February 14, Sunday.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
An introduction to the debugger And jGrasp editor-syncrasies (ideosyncrasies)
National Diploma Unit 4 Introduction to Software Development Data Structures – Loops and selection.
Do not put content on the brand signature area NOBS for Noobs David B. Horvath, CCP, MS PhilaSUG Winter 2015 Meeting NOBS for Noobs.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
SAS ® 101 Based on Learning SAS by Example: A Programmer’s Guide Chapters 14 & 19 By Tasha Chapman, Oregon Health Authority.
Working Efficiently with Large SAS® Datasets Vishal Jain Senior Programmer.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. 4 Simple Flow of Control.
Introduction to C Topics Compilation Using the gcc Compiler
Working with Java.
Chapter 1 Introduction to Computers, Programs, and Java
MIPS assembly syntax Comments
Introduction to C Topics Compilation Using the gcc Compiler
2.1 Parts of a C++ Program.
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Python 4 and 5 Mr. Husch.
Python 8 Mr. Husch.
Introduction to C Topics Compilation Using the gcc Compiler
Presentation transcript:

Writing Maintainable Code with ‘Style’ Allan Page Senior Marketing Analyst Canadian Tire Bank

Valid SAS Code can be hard to read!

Starting each statement on a new line helps

Blank lines are good for step separation.

Indentation helps define processes within a step.

Indentation is good with do/end groups too.

Use tab stops to line up repeated code.

Add comments to say what’s happening.

Comments have different styles.

A misplaced comment! 1 data one; NOTE: SCL source line. 2 set sasuser.whse *comment;; ERROR: File WORK.COMMENT.DATA does not exist. ERROR : Syntax error, expecting one of the following: a name, a quoted string, (, ;, END, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_. ERROR : The option or parameter is not recognized and will be ignored. 3 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.ONE may be incomplete. When this step was stopped there were 0 observations and 3 variables. NOTE: DATA statement used: real time 0.18 seconds cpu time 0.09 seconds

Number Code Sections /*=====================================================================+ | trs07.sas 20 | | Set the initial file. | +======================================================================*/ data _null_; set exp; call symput ("mtoday",today()); call symput ("topics",0); -- more code -- /*=====================================================================+ | trs07.sas 30 | | Global statements for macros. | +======================================================================*/ %global asterisk tq crse instn bbase form1 partone parttwo parthre partfiv partsix partsvn partegt partnin partten parteln parttwv partthr part813 wtblnk quizname webcrse webct dsn;

Use numbers in program names.  Program names END START would not sort in their required run sequence.  Program names 001STARTand 002END would be properly ordered.

Use date functions instead of hard-coding dates in your programs. data _null_; call symput('lstmth',put(intnx('month',date(),-1,'end'),date9.)); run; %put lstmth= &lstmth; lstmth= 30SEP2004

Questions or Comments?

Copyright © 2003, SAS Institute Inc. All rights reserved. 15