05-12-2015 06:20 PM
Hello everyone. Is there an option that controls how long of a code line you can have in a given sas program before it gets cut off and the program fails.
Example: If you have a sas program which you call using an %include statement, something like the following will fail because the line is too long.
/*this text comment is way too long. For some reason sas cuts off the line length at a specific position (i'm guessing 256). therefore it doesn't read the end of the comment which and as such it reads in the rest of a program as a comment. I am not sure why this happens. This is a contrived example, but I have programs that have 8-10 loops deep in the code, and as such use 8-10 tabs in to make sure the program is readable. When that happens the code is failing because some of the lines are far too long given the 8 tabs that are necessary for proper coding indentation. Please let me know if this eample doesn't make sense*/
THanks all and let me know if anyone has any questions!
05-12-2015 06:35 PM
There are quite a number of SAS notes on this subject if you search the SAS support site. Here is one to get started. Your guess is correct that 256 characters is often the default but it is also dependent on how you are submitting your programs:
05-13-2015 08:15 PM
I have to ask... Why would this be a limitation that would ever be put in place? if anyone ever wants to indent their code to any reasonable level you are going to quickly run into all of these limits, causing some pretty distinct problems that are very hard to debug.
Just curious if anyone knows why this is true.
05-13-2015 10:37 PM
Can't give you an answer to why, but doesn't seem hard to debug to me. My log shows a warning:
241 %include "d:\junk\longLinedInclude.sas"/source2; 242 +%macro example; 243 + WARNING: Truncated record. 244 +/*this text comment is way too long. For some reason sas cuts off the line length at a 244!+specific position (i'm guessing 256). therefore it doesn't read the end of the comment 244!+which and as such it reads in the rest of a program as a comment. I am not sure w 245 + 246 +data shouldrun; 247 +doesitrun='no'; 248 +run; 249 +%mend example; 250 +%example NOTE: %INCLUDE (level 1) ending.
Most folks try to keep their code narrow enough that it fits in the width of one screen. Even with indenting, I would think exceeding 256 characters long would be rare. You can reduce the number of spaces inserted when you press the tab key. I have it set to 2 spaces.
05-14-2015 01:00 AM
I believe at one point coding best practice was 70 chars. Something about screen size snd ideal readability.
As to ease of debugging it took me a week to figure out but never forget it after that. .
05-14-2015 09:00 AM
To add to the good advice above, I wouldn't recommend the use of tabs to indent, use two spaces or something, as tabs are rendered differently in different applications. You can actually set SAS up to do it automatically - Tools-Options-Enhanced Editor.
05-13-2015 11:41 PM
In my opinion program code should be laid out so it is easily readible on a screen, just like printing in books. If you do that then you you will never strike the 256 character limit. I never have!
05-14-2015 08:47 AM
You guys are too YOUNG!!
Punched cards had 80 columns, and the last 8 were frequently used for sequence numbers, therefore (drum roll please...)
generations of coders of my era compulsively keep our lines of code to 72 characters or less.