SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
bizbaz20
Calcite | Level 5

Hi everyone,

 

I'm experiencing an issue with indentation in SAS Enhanced Editor. I manually indent my code using spaces instead of tabs, but whenever I reopen a SAS program, random extra spaces are added to my code. The number of added spaces is inconsistent—some lines get one extra space, while others get six or seven. When I delete these (using backspace or delete keys), sometimes it will delete the entire space in one go, but not always.

 

This only happens to the sections of code that I have written, even in programs where multiple programmers have contributed. It’s becoming very time-consuming to fix the indentation every time I open a program.

 

I'm using SAS 9.4 (M5) - 64-bit. Has anyone else experienced this issue, or does anyone know how to prevent SAS from modifying my indentation?

 

Thanks in advance!

7 REPLIES 7
Tom
Super User Tom
Super User

Make sure you have told the editor to NOT put tabs into the file.

Tom_0-1741624544899.png

If you already have that then perhaps someone else has edited the file and replaced the spaces with tabs?

bizbaz20
Calcite | Level 5

Hi, these are my settings currently. Would it be 'Replace tabs with spaces on file open'? It isn't to do with anyone else editing the files as I have just tested it with a colleague who didn't edit anything and the same issue occurred. 


bizbaz20_0-1741624839717.png

 

 

Tom
Super User Tom
Super User

With those setting if you hit the TAB key on your keyboard the editor will actually put a physical '09'x character into the file. 

 

And if you open a file to edit that has physical tabs that were inserted using some other setting than 2 as the width of the tab stops then it will look funny.

 

Having actual physical tab characters in your file can cause all kinds of confusion after just a few simple edits.

ballardw
Super User

@bizbaz20 wrote:

Hi everyone,

 

I'm experiencing an issue with indentation in SAS Enhanced Editor. I manually indent my code using spaces instead of tabs, but whenever I reopen a SAS program, random extra spaces are added to my code. The number of added spaces is inconsistent—some lines get one extra space, while others get six or seven. When I delete these (using backspace or delete keys), sometimes it will delete the entire space in one go, but not always.

 

 


The highlighted text above indicates that TAB characters are in the file.

Note that the SAS auto indent will use tabs (which your editor settings can be made to save as spaces) even if you typically use the space key.

 

And if multiple people are editing the files then different settings of the editors for number of spaces a tab represents might come into play.

Tom
Super User Tom
Super User

@ballardw wrote:

...

Note that the SAS auto indent will use tabs (which your editor settings can be made to save as spaces) even if you typically use the space key.

...


There are two options you can set in the Enhanced Editor to manager this behaviour.

Tom_0-1741704528047.png

Selecting the first makes SAS do the opposite of what you say.  When you type the TAB key spaces are inserted into the file instead of an actual TAB character.

The second controls what happens when you open an existing file.  When selected existing tabs are replaced by spaces so that you can edit the file without worrying that copying text will cause tabs to appear in unwanted places.

 

 

bizbaz20
Calcite | Level 5

Thank you for explaining those options. I have now ticked both options and turned off automatic indentation. It hasn't happened since, but I will check some of my programs tomorrow. 

 

I checked my original settings against my colleagues, and they both match. Nor have they edited or opened the scripts in question, so I don't think it relates to other people editing it. 

Tom
Super User Tom
Super User

Not sure where SAS stores that EE settings.

 

But for normal preferences they are stored in the SASUSER.PROFILE catalog.  And if you are running multiple SAS sessions without using the -RSASUSER option on startup then the 2nd,3rd,etc. sessions will not be able to open SASUSER.PROFILE.  So you end up getting a default profile instead of your persona; preferences.  That might change the tab spacing from 2 to 8 and cause a file with mix of tabs and spaces to look funny.

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Save $200 when you sign up by March 14!

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 279 views
  • 0 likes
  • 3 in conversation