BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
whymath
Lapis Lazuli | Level 10

As far as I know, there are three kinds of ways to add comment in SAS: 

 

*Any comment text here; 
%*Any comment text here; 
/*Any comment text here*/

 

This afternoon, I am kind of excited of finding the fourth way to add comment by coincidence. It is: 

comment Any comment text here;

 

As you can see, the first word comment is a keyword here to trigger the following text becoming comment text. I have tried several programs:

 

/*comment of macro in open code*/ 

%put This is %sysfunc(date(),e8601da.); 

comment %put This is %sysfunc(date(),e8601da.); 

/*comment of macro*/ 

comment %cmprs(test); 

/*comment after normal statement*/ 

data _null_; 
comment Hi there.; 
run;

 

They all behaves like a normal comment way. Only one point, there mustn't exist a semicolon in the comment text. I think there is enough exploration in SAS. I search in the help document and find nothing. My friend tells me this may be a pre-experience features, How do you know about it?

 

Please share your idea.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

It is not new.  I suspect that SAS has just removed it from the documentation, perhaps like the way PROC DELETE disappeared for a while.

 

Here is an old article that mentions it.

https://www.sascommunity.org/mwiki/index.php?title=Comment_statement

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

It is not new.  I suspect that SAS has just removed it from the documentation, perhaps like the way PROC DELETE disappeared for a while.

 

Here is an old article that mentions it.

https://www.sascommunity.org/mwiki/index.php?title=Comment_statement

WarrenKuhfeld
Rhodochrosite | Level 12

The COMMENT statement is really old. SAS tends to support almost everything that it ever did, but it does not necessarily keep documenting something that almost no one would ever use now days. I believe it traces its roots to FORTRAN comments. I'll bet it dates back to the 1970s.

PaigeMiller
Diamond | Level 26

Another way to comment text, particularly if you want to comment large blocks of code that may already have comments.

 

%if 0 %then %do;

your comments go here

%end;

--
Paige Miller
Astounding
PROC Star

A very useful method of designating a block of code as a comment is to define it as a macro.  For example, suppose you make some changes to the beginning of a program and want to test the changes before running the entire program.  Right now the program looks like this:

Beginning of program that contains some changes

The rest of the program that should only run once the changes are debugged

You could modify the program in this way:

Beginning of the program that contains some changes

%macro skip;
The rest of the program that should only run once the changes are debugged
%mend skip;

By defining the rest of the program as a macro, you can skip it until the earlier changes are debugged.

PaigeMiller
Diamond | Level 26

@Astounding provides a sixth way to comment out code! (One I have used myself!)

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 5690 views
  • 6 likes
  • 6 in conversation