I have seen numerous headers in SAS programs and not all of them contain the same information. A header in a SAS program should contain enough information to get a quick overview of the program, but not information that is redundant. For example, most headers contain information about changes done to the program (change date, author and so on), but if you know that the program is not to be modified, this part is redundant and should be omitted. This post shows an example of how to add a standard header abbreviation in your SAS editor.

I like to have a relatively short and easily readable header. Below is the description I use in all of my programs.

/*****************************************************************************************************************
 
SAS file name: Standard_Header.sas
File location: The location of the SAS file
__________________________________________________________________________________________________________________
 
Purpose: Shortly explain the overall purpose of the code
Author: The name of initial author
Creation Date: Date of creation
 
Some text explaining the program. Perhaps an example call of a macro/module
 
__________________________________________________________________________________________________________________
 
CHANGES:
 
Date: Date of first modification of the code
Modifyer name: Name of the programmer who modified the code
Description: Shortly describe the changes made to the program
 
*****************************************************************************************************************/

Adding an Abbreviation

SAS Standard Header ExampleInstead of having your standard header in a separate file and copy/pasting it into your editor each time you create a new SAS program, you can add an abbreviation to quickly insert your header.

You can do this by going to Tools –> Add Abbreviation.

Now type in the abbreviation and the text you want to be inserted in your editor and hit OK.

Now, whenever you type in eg “header” in your editor, SAS presents you the opportunity to insert your header for you. Hit Enter to insert the header.

To see another example of adding abbreviations in SAS, see the post Save Typing And Add Abbreviation In SAS. Adding abbreviations is one way to make coding in SAS more convenient. I present another in the blog post Clear Log And Results Window In SAS.

Summary

A program header should be present in all of your programs. Documenting code is one of the most important parts of being a programmer. However, too many programmers do not document properly. Sometimes because they are too busy and sometimes because they think they can remember every little detail of the program logic. And why they wrote it. But they are wrong. No programmer can remember every little part of their code or logic. Furthermore, you are probably not the only one who will use your programs. Therefore, you should think about how to make your code as readable as possible. Writing proper documentation is a huge part of this.

For a great introduction to how to properly document your code, see the article Common Sense SAS – Documenting and Structuring Your Code.

You can download the entire standard header example code from this post here.