user12586
user12586

Reputation: 225

Commenting out sections of code for testing

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.

Upvotes: 1

Views: 2031

Answers (3)

Robert Penridge
Robert Penridge

Reputation: 8513

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 statements
  • noexec and cancel statements
  • options 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

Upvotes: 1

sasfrog
sasfrog

Reputation: 2460

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;

Upvotes: 4

RosaryGuy
RosaryGuy

Reputation: 43

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.

Upvotes: 2

Related Questions