SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
xyxu
Quartz | Level 8

I often see others' well-aligned program header comments (e.g., see below), but I still have no idea how the authors made them. Is there a keyboard shortcut that allows us to align comments?

 

xyxu_0-1659244472994.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

I'm with @Tom  on this one. This is how I do it: it is still as tidy but you don't waste time having comment blocks on each line:

 

SASKiwi_1-1659302888395.png

 

View solution in original post

6 REPLIES 6
ballardw
Super User

Not in an editor supplied by SAS that I am aware of.

Some people use other-than-SAS-supplied editors that have features that do that. Others insert spaces manually and use a monospace font.

 

The Enhanced Editor in Display Manager (sometimes called Base or PC SAS) with the Ctrl-/ key will put /* */ comment characters at the start and end of each line of a block of highlighted text. So the padding with spaces at the end is sometimes not too much headache.

FreelanceReinh
Jade | Level 19

Hello @xyxu,

 

Good question. Maybe they use a large "Tab size" in the Enhanced Editor Options (Tools → Options → Enhanced Editor...). For example, with a setting of 83 (spaces) I can place the cursor exactly where the closing "*/" is located in your example with a single keystroke after a shorter line of text (where "shorter" can be anything between 0 and 82 characters). If the "Insert spaces for tabs" checkbox is not selected, those closing "*/" characters do not move even if the comment text is edited and its length changes (within the range of 0 to 82 characters).

 

The horizontal border lines and separators ("/* ----...") could be created easily with a user-defined keyboard macro. Also an entire blank program header can be created that way or loaded from disk (with the checkbox "Replace tabs with spaces on file open" not selected).

 

Personally, I don't like tabs in my code files so I don't use the above settings. But for those alignment purposes they might come handy.

WarrenKuhfeld
Ammonite | Level 13

I did that extensively when I was employed at SAS. I used emacs as my editor along with some customized commands that made it easy. As a primitive alternative, create an otherwise blank line with just the leading /* and */, then copy it multiple times and type over the blanks using overwrite. That said, if you don't have specialized commands for it, it is much easier not to do it.

Kurt_Bremser
Super User

In my EG Enhanced Editor, I had a keyboard macro which would write the complete program header, including the nicely formatted comment block. I would then fill it in replace mode.

Tom
Super User Tom
Super User

My advice is don't bother.  It does not really make the comments any easier to read.  And it definitely makes them much harder to keep up to date.  I have seen too many programs that failed because one of those * or */ characters at the end of the line got pushed off the screen and so the programmer never noticed it was there.

 

If you insist on creating such things then use the normal old program editor in SAS Display Manager it will let you type */ in column 75 without typing anything before it.  That feature does not exist in the "Enhanced" program editor.

SASKiwi
PROC Star

I'm with @Tom  on this one. This is how I do it: it is still as tidy but you don't waste time having comment blocks on each line:

 

SASKiwi_1-1659302888395.png

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 6 replies
  • 1981 views
  • 5 likes
  • 7 in conversation