Amadeus cookies policy - you'll see this message only once.

Amadeus use cookies on this website. They help us to know a little bit about you and how you use our website, which improves the browsing experience and marketing - both for you and for others. They are stored locally on your computer or mobile device. To accept cookies, continue browsing as normal. Or, go to the privacy policy for more information.

You May Very Well Think That…

… they’re a waste of time, but I couldn’t possibly not comment!  

The writing of comments is an important part of any programming task. Without them, you yourself might not understand your own code in a year’s time – so spare a thought for any other poor devil who may have to maintain it.  

SAS provides two standard forms of comment:  

* Those introduced by an asterisk and terminated by a semicolon;

/* And those introduced by slash asterisk and terminated by asterisk slash */  

The first kind is usually preferable. This leaves the second kind available for those times when you want to comment out a whole block of code – this would not work if the block included “/* .. */” comments already.  

The trick that overcomes this problem is to turn the block of code into a dummy macro thus:  

%macro never_to_be_executed;

%* This line is a macro comment, which generates no code;

%* If the macro were executed, it would generate three lines of code,

   including the two ordinary comments below;

* Those introduced by an asterisk and terminated by a semicolon;

/* And those introduced by slash asterisk and terminated by asterisk slash */

put 'This statement will not now be executed';

%mend never_to_be_executed;  

Within your comments, make a point of not including anything that might conceivably confuse SAS – however sure you are that SAS ought not to be confused! So do not under any circumstances use within your comments:  

  • semicolons
  • apostrophes (say “do not” and “cannot” rather than “don’t” and “can’t”)
  • percent signs
  • ampersands
  • any other interesting punctuation  

You may find that such punctuation causes no trouble when your code is run in the normal way – but there is more than one way to run SAS code. One day your little gem may be turned into a macro, and invoked from SAS code submitted from SCL, and you will find – eventually - that the apostrophe you thought you had got away with has caused all kinds of mayhem.  

Oh, and remember the useful line: 

            */*; 

which will close either kind of comment, and do no harm if none is in progress.