UWA Logo
  Planning Services | Statistics Office | IRU | EIS    
           
University Statistics
Internal
Contacts

SAS Programming Standards

Program Header

Make sure your programs include some sort of header, showing at least your name, the date, and the purpose of the program. And if you’re updating an existing program then remember to update the header. Have pity on the next victim who needs to modify it - they need all the help they can get. Here’s an example –

*--------------------------------------------------------------------------;

*  Staff FTFFT Variance Report.sas  

*  ~~~~~~~~~~~~~~~~~~~~~

*

*  2009 STATISTICS

*

*  Program description

*

*  This program produces a report comparing this year's FTE for FT/FFT staff with last year's, by

*  OU group, org unit, dept, classification & level. This is used to check for any coding

*  errors while preparing the DEEWR 1055FTyyyy.100001 file.

*

*  Input/Output :

*

*  I  deetYY.st0005    - Last year's FT/FFT dataset.

*     deetYY-1.st0005  - This year's FT/FFT dataset.

*

*  O  Group206_FT.htm -  Form 206 difference report

*

*  History:

*

*  Date          By             Purpose

*  ~~~~            ~~             ~~~~~~~

*  01-07-2008   Murray Rivers   New for 2008

*  02-07-2009   Lady Hawke       Add extra table with function breakdown

*--------------------------------------------------------------------------;

White Space

Leave at least a one-line gap between steps - it's much easier to read this way.

 

/* Sort so that the table displays data in desired order */

proc sort data=ft;

  by aou_grp dept org_unit function classification level;

run;

 

 

proc summary data=ft nway;

  class aou_grp org_unit classification;

  var fte&yy. fte&yy_1. diff;

  output out=table1 (drop = _TYPE_ _FREQ_) sum=;

run;

 

 

Indentation

 

Use indentation consistently. Here’s one technique –

 

data table1;

    set table1;  * within data step or procedure, indent by one tab;

 

    /* calculate percentage increase in fte */

    if fte&yy_1. EQ 0

       then diff_percent = 0.999;

       else diff_percent = (diff/fte&yy_1.);

run;

 

Comments

 

There are two types of comment –

 

/* 1. this is the first type of comment */

 

* 2. this is the second type of comment ;

 

The second type shouldn’t be used within macros - SAS sometimes gets confused about where they end.

Insert comments to explain why you're doing something if it isn't obvious

Read the Log

Even if the program seems to execute without error, you must still read the log to pick up warnings or notes. You may have inadvertently created extra records via a merge, or overwritten an existing dataset without knowing.

Further Information

www.lexjansen.com

www.sas2.com

www.scsug.org

 

Top of Page