BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mirmir
Calcite | Level 5

Hi! I'm new to SAS and mostly programmed in Java before. In Eclipse, you adjust the settings so that there would be a line signalling a certain number of characters, so you wouldn't write lines of code that were too long and unreadable. 

 

Is there something similar in SAS EG? I'd like to make my code more clear/consistent, especially long block comments.

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Hi, the EG editor doesn't have that feature to indicate long lines or force breaks, but it does have a decent code formatter that will break up long lines (where possible).  

 

Try it out and see how it works for you.  Ctrl+I (for "indenter") or right-click, Format Code.

 

In EG 8.1, the default keyboard shortcut for the code formatter changed to Ctrl+Shift+B.  And in EG 8.2, you can manage many of these shortcut keys (Tools->Manage Keyboard Shortcuts).

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

8 REPLIES 8
ballardw
Super User

The length of a variable in a data set is determined by first use. If the variable comes from an existing data set via a SET MERGE UPDATE or MODIFY statement and that is the first use then that is the length. If the variable is in multiple data sets and has different lengths then the warning is generated to let you know some potential for truncated data exists. The message would have no relationship to the length of any code or comment lines.

 

You can prevent a data truncation issue by using a LENGTH statement before the SET, Merge etc, referenced data sets.

 

Data newdata;

    length problemvar $ 50;

    set data1 data2;

run;

for example. Recommendation would be to examine the lengths of the variable(s) involved and use the longer of the two in that particular Length statement.

Best of course would be create the data sets with identical variables with the same length to begin with for consistency.

 

I don't use the EG interface so I'm not aware of any editor features such as you mention.

Reeza
Super User

I think the OP means the text editor, ie the Program editor enforces a line limit of 90 characters so a line of code has to be under 90 characters or goes to a new line. 

 

 

 

 

ChrisHemedinger
Community Manager

Hi, the EG editor doesn't have that feature to indicate long lines or force breaks, but it does have a decent code formatter that will break up long lines (where possible).  

 

Try it out and see how it works for you.  Ctrl+I (for "indenter") or right-click, Format Code.

 

In EG 8.1, the default keyboard shortcut for the code formatter changed to Ctrl+Shift+B.  And in EG 8.2, you can manage many of these shortcut keys (Tools->Manage Keyboard Shortcuts).

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
ecbiss
Calcite | Level 5

I am using EG, and Ctrl+I does not appear to be breaking up longer lines.

ChrisHemedinger
Community Manager

In EG 8.1, the default keyboard shortcut for the code formatter changed to Ctrl+Shift+B.  And in EG 8.2, you can manage many of these shortcut keys (Tools->Manage Keyboard Shortcuts).

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Reeza
Super User
If you end up deciding to use a different code editor, NotePad++ is a decent option.
ChrisHemedinger
Community Manager

...and you can launch Notepad++ (or your other favorite editor) from within EG -- see Tip #10 in this post.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
Kurt_Bremser
Super User

It's funny. I seem to be so used to my own "80 characters are enough" rule (also see Maxim 12) that I usually skip to the next line before I reach column 80.

 

But yes, EG does not have a mechanism to enforce that (semi-)automatically. You might add a SASWare Ballot idea for this.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 8 replies
  • 4014 views
  • 6 likes
  • 6 in conversation