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.
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
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
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.
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;
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.
@Astounding provides a sixth way to comment out code! (One I have used myself!)
End of line comments are badly needed in my opinion.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.