I want to comment out everything, say, after line 26 of a SAS program for a debugging purpose. endsas
terminates everything including the SAS program but I want the program to remain and check the outcome. Please advise the steps.
Asked
Active
Viewed 1,874 times
3 Answers
4
Following on from @RosaryGuy's good answer:
* anything between an asterisk and semicolon will be commented out;
/* anything between a slash-asterisk and asterisk-slash will be commented out */
%macro ignore; This whole section, between '%macro ignore;' and '%mend;', including any comments of any kind, any other macro calls, and any syntactically incorrect code etc. will be compiled at execution time but never run. You should use this to 'comment out' large sections of code that may already have comments in them. %mend;

sasfrog
- 2,410
- 1
- 17
- 28
-
1If you have unbalanced quotation marks, this won't work, because the %mend will be read as part of a quoted string instead of ending your ignore macro. For example, this very comment would break that ignore macro (because there is an odd number of apostrophes in this comment, which counts as unbalanced single quotes). – Max Power Feb 16 '16 at 19:04
2
A couple of thoughts:
1) Hold down 'control key and forward slash to comment out line by line.
2) Put code between %macro somename and %Mend
Do not use endsas unless you want to instantly shut down your session.
I hope this helps.

RosaryGuy
- 43
- 2
1
The accepted answer (by cmjohns) to this slightly different question (In SAS, what are good techniques/options for catching syntax errors?) contains about every conceivable way to comment code.
This includes doing it via:
Comments
- both kinds%include
statements%macro
statementsnoexec
andcancel
statementsoptions obs=0 noreplace;
- this isn't covered in the linked PDF but it is covered in the question
It also contains handy tips and shortcuts for each of the above methods.
The details are in the link to this PDF

Community
- 1
- 1

Robert Penridge
- 8,424
- 2
- 34
- 55