<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Are two ways of comments in SAS interchangeable inside a datastep? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722772#M224164</link>
    <description>&lt;P&gt;Someone else will reply with all of the various comment mechanisms in SAS, but &lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=n1v51exifva71an1cvfn2z6j26lo.htm&amp;amp;locale=en" target="_self"&gt;I'll refer you to this doc&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "* ;" style of comment must be expressed as a separate statement, so you cannot embed it inside another statement as you did in your example.&amp;nbsp; You could place a "/* */" style of comment in there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So not this:&lt;/P&gt;
&lt;PRE&gt;if A or B&lt;BR /&gt;* my comment;&lt;BR /&gt;and C&lt;BR /&gt;;&lt;/PRE&gt;
&lt;P&gt;But this is okay:&lt;/P&gt;
&lt;PRE&gt;if A or B&lt;BR /&gt;/* my comment */&lt;BR /&gt;and C&lt;BR /&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also get very explicit with the COMMENT statement instead of that asterisk, but that's rarely done and not documented any longer, I think:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 comment This is a comment;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Mar 2021 03:14:23 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2021-03-02T03:14:23Z</dc:date>
    <item>
      <title>Are two ways of comments in SAS interchangeable inside a datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722765#M224159</link>
      <description>&lt;P&gt;Hi SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Normally I treated two ways of comments in SAS (&lt;STRONG&gt;/*&amp;nbsp; &amp;nbsp;*/&lt;/STRONG&gt; and &lt;STRONG&gt;*&amp;nbsp; &amp;nbsp; ;&lt;/STRONG&gt;) similarly. I normally use the shortcut &lt;STRONG&gt;Ctr /&lt;/STRONG&gt;&amp;nbsp; to make the comment line so did not notice the difference between these two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, today I want to separate the comment way to make my code aesthetically. For example, I want to let the comment outside the datastep as &lt;STRONG&gt;/* */&lt;/STRONG&gt; while the comments inside the datastep is &lt;STRONG&gt;* ;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It turns out as below&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data filter_;
	set my.keepvar_1999_2001_1;
	*Sufficient 3 componenst t calculate return and adjusted price;
	 if n(ajexdi,prccd,trfd)=3 or n(prccd,prchd,prcld)=3
	 /**/
	 and
	 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_0-1614651564912.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55338i9A7816F07F7DBB25/image-size/large?v=v2&amp;amp;px=999" role="button" title="My97_0-1614651564912.png" alt="My97_0-1614651564912.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As you can see from the picture, the word and turned red and &lt;STRONG&gt;* ;&lt;/STRONG&gt; seem not to work while they are still black (I did not post the code because the code here did not show the red and black colors of what I want to impress)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am wondering if I fall into any fallacy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 02:22:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722765#M224159</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-02T02:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Are two ways of comments in SAS interchangeable inside a datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722772#M224164</link>
      <description>&lt;P&gt;Someone else will reply with all of the various comment mechanisms in SAS, but &lt;A href="https://go.documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=n1v51exifva71an1cvfn2z6j26lo.htm&amp;amp;locale=en" target="_self"&gt;I'll refer you to this doc&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "* ;" style of comment must be expressed as a separate statement, so you cannot embed it inside another statement as you did in your example.&amp;nbsp; You could place a "/* */" style of comment in there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So not this:&lt;/P&gt;
&lt;PRE&gt;if A or B&lt;BR /&gt;* my comment;&lt;BR /&gt;and C&lt;BR /&gt;;&lt;/PRE&gt;
&lt;P&gt;But this is okay:&lt;/P&gt;
&lt;PRE&gt;if A or B&lt;BR /&gt;/* my comment */&lt;BR /&gt;and C&lt;BR /&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also get very explicit with the COMMENT statement instead of that asterisk, but that's rarely done and not documented any longer, I think:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
 comment This is a comment;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 03:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722772#M224164</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2021-03-02T03:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: Are two ways of comments in SAS interchangeable inside a datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722773#M224165</link>
      <description>&lt;P&gt;There are three types of comments: PL/1 style, asterisk style, and macro style.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.PL/1 style comments are processed in the SAS word scanner, character by character. /* This comment's bytes are processed character by character. */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Asterisk style comments are processed in the tokenizer, token by token, until a semicolon is reached. However, single and double quotation marks are treated as special tokens, so that string literal tokens are NOT built in this case. * Asterisk comments are read token by token but quotes are treated like single tokens.; (However, inside a macro definition, they are gathered as constant text. So the constant text is built with tokenization rules, including string literal tokens.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Macro style comments are processed by the macro facility, token by token, until a semicolon is reached. Single and double quotation marks build string literals, so every open quotation mark must have a closing quotation mark. %* This macro comment is read token by token until the semicolon.;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 03:19:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722773#M224165</guid>
      <dc:creator>qoit</dc:creator>
      <dc:date>2021-03-02T03:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: Are two ways of comments in SAS interchangeable inside a datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722975#M224271</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am totally impressed by the last method, you are right, I have never seen such an explicit way of comment before.&lt;/P&gt;
&lt;P&gt;I did some searches but did not find out how to use this comment way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can I ask whether I can use it interchangeably with &lt;STRONG&gt;/*&amp;nbsp; */&amp;nbsp;&lt;/STRONG&gt;?&lt;/P&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 21:01:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722975#M224271</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-02T21:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: Are two ways of comments in SAS interchangeable inside a datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722977#M224272</link>
      <description>&lt;P&gt;No, COMMENT...; is a statement. And technically *....; is a statement -- so you cannot place these within other statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/* ... */ is the most flexible (and familiar to those who may have encountered this style in other programming languages). But long-time SAS programmers may have their favorite methods of using different comment styles to adorn their code.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 21:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722977#M224272</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2021-03-02T21:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Are two ways of comments in SAS interchangeable inside a datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722979#M224273</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to argue about this part,&lt;/P&gt;
&lt;P&gt;I am wondering why I can put COMMENT inside another statement as below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My97_0-1614719474947.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55375i44D3DD9A4B186CAC/image-size/large?v=v2&amp;amp;px=999" role="button" title="My97_0-1614719474947.png" alt="My97_0-1614719474947.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(This code is run successfully)&lt;/P&gt;
&lt;P&gt;That is why I asked if COMMENT...; is interchangeable with /*...*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 21:12:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722979#M224273</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-02T21:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: Are two ways of comments in SAS interchangeable inside a datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722985#M224275</link>
      <description>&lt;P&gt;In SAS, a&amp;nbsp;&lt;STRONG&gt;statement&lt;/STRONG&gt; is a keyword, perhaps followed by some arguments/data, terminated by a semicolon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DATA step is a "step" (just like PROC steps are steps), and may contain multiple statements. Here's a crude diagram.&lt;/P&gt;
&lt;DIV id="tinyMceEditorChrisHemedinger_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-03-02_16-19-17.png" style="width: 517px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55377i6C8DEE89EA202246/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-03-02_16-19-17.png" alt="2021-03-02_16-19-17.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You cannot add a "statement-style comment" inside a statement (like between "set" on line 2 and its terminating semicolon).&amp;nbsp; But you could insert a /* */ block in there.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 21:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722985#M224275</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2021-03-02T21:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Are two ways of comments in SAS interchangeable inside a datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722986#M224276</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for my mistake about the misunderstanding between the statement and data step, it is clear now.&lt;/P&gt;
&lt;P&gt;So I can wrap up things like that if I want to adorn my code:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;*...;&lt;/STRONG&gt; for comment outside datastep&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;comment&lt;/STRONG&gt; statement for inside datastep but outside statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;/*...*/&lt;/STRONG&gt; for inside data statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, it looks great then.&lt;/P&gt;
&lt;P&gt;Warm regards.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 21:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Are-two-ways-of-comments-in-SAS-interchangeable-inside-a/m-p/722986#M224276</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-02T21:31:24Z</dc:date>
    </item>
  </channel>
</rss>

