Macro line limit for compilation

Reply
Super Contributor
Posts: 418

Macro line limit for compilation

    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.

%macro example;

/*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*/

data shouldrun;

doesitrun='no';

run;

%mend Example;

%example;

THanks all and let me know if anyone has any questions!

Super User
Posts: 3,256

Re: Macro line limit for compilation

Posted in reply to Anotherdream

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:

15883 - Length limitations when submitting SAS code

Super User
Posts: 19,822

Re: Macro line limit for compilation

Posted in reply to Anotherdream

And in the first paragraph the LRECL= option to override the 256 character limit.

%include 'program with long lines.sas' /lrecl=500;

Super Contributor
Posts: 418

Re: Macro line limit for compilation

Posted in reply to Anotherdream

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.

PROC Star
Posts: 1,322

Re: Macro line limit for compilation

Posted in reply to Anotherdream

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.

Super User
Posts: 19,822

Re: Macro line limit for compilation

Posted in reply to Anotherdream

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. .

Super User
Super User
Posts: 7,970

Re: Macro line limit for compilation

Posted in reply to Anotherdream

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. 

Super User
Posts: 3,256

Re: Macro line limit for compilation

Posted in reply to Anotherdream

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!

PROC Star
Posts: 1,167

Re: Macro line limit for compilation

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.

Creakily yours,

  Tom

Respected Advisor
Posts: 3,156

Re: Macro line limit for compilation

Come'on, Tom. Mainframe and COBOL is still very much vibrant in industry Smiley Happy.

Ask a Question
Discussion stats
  • 9 replies
  • 1085 views
  • 2 likes
  • 7 in conversation