The "Format code" option might incorrectly add an extra semicolon in SAS® Enterprise Guide® programs


If you use the Format code option from the context menu to format your code in a SAS Enterprise Guide program, an extra semicolon might incorrectly be added into the code. Consequentially, the code fails with an error.

This error is most likely to occur when the code contains a DO loop within an IF-THEN/ELSE statement.

Here is example code that triggers the issue when formatted with the Format code option:

data test;
    set sashelp.cars;
    if Origin EQ "Asia" then
        do i=1 to 2;
            output;
        end;
    else if Origin EQ "Europe" then
        do i=1 to 3;
            output;
        end;
run;

Here is how the formatted code appears:

Note: The extra incorrect semicolon is highlighted.

data test;
    set sashelp.cars;
    if Origin EQ "Asia" then
        do i=1 to 2;
            output;
        end;
    else if Origin EQ "Europe" then
        do;
            i=1 to 3;
            output;
        end;
run;