Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Writing Maintainable Code with ‘Style’ Allan Page Senior Marketing Analyst Canadian Tire Bank."— Presentation transcript:

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

2 Valid SAS Code can be hard to read!

3 Starting each statement on a new line helps

4 Blank lines are good for step separation.

5 Indentation helps define processes within a step.

6 Indentation is good with do/end groups too.

7 Use tab stops to line up repeated code.

8 Add comments to say what’s happening.

9 Comments have different styles.

10 A misplaced comment! 1 data one; NOTE: SCL source line. 2 set sasuser.whse *comment;; - 22 ------- 202 ERROR: File WORK.COMMENT.DATA does not exist. ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, ;, END, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_. ERROR 202-322: 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

11 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;

12 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.

13 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

14 Questions or Comments?

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


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

Similar presentations


Ads by Google