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.
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).
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.
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.
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).
I am using EG, and Ctrl+I does not appear to be breaking up longer lines.
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).
...and you can launch Notepad++ (or your other favorite editor) from within EG -- see Tip #10 in this post.
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.