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.
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
This option formats the program with indentation and separates sections of code with blank spaces.
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'.