Amadeus cookies policy - you'll see this message only once.

Amadeus use cookies on this website. They help us to know a little bit about you and how you use our website, which improves the browsing experience and marketing - both for you and for others. They are stored locally on your computer or mobile device. To accept cookies, continue browsing as normal. Or, go to the privacy policy for more information.

Code Formatting in SAS Enterprise Guide

When writing code, it is good practice to use indentation. Indentation allows us to distinguish between conditional statements and nest code within loops whilst still being able to see where a loop starts and finishes.

Most companies make it a policy to indent code as it enables reviewers to clearly see what is happening in the code and be able to debug problems effectively.

In SAS® Enterprise Guide 4.3 onwards, SAS introduced a format code function which will helpfully indent programs and separate multiple statements onto individual lines.

Below is an example of a SAS program where indentation has not been applied. As can be seen, it is difficult to identify where conditional code blocks start and finish.

Code Formatting with SAS Enteprise Guide 1

Opening a SAS program in SAS Enterprise Guide, the user can select the Edit dropdown menu followed by the 'Format Code Ctrl+I' option, or can select this by right clicking inside the program window or by holding the keys CTRL + I

Code Formatting with SAS Enterprise Guide 2

This option formats the program with indentation and separates sections of code with blank spaces.

Code Formatting with SAS Enterprise Guide 4 

The settings that SAS use to control how many spaces are used to indent the code, along with options such as inserting a blank space before an IF statement are customisable.

The Enhanced Editor Options can be located from the Program dropdown menu followed by the 'Editor Options…' and selecting the 'Indenter Tab'.