<?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: How to put a group of code to comment quickly ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724313#M224875</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Amazing and hand-on suggestion, thank you very much.&lt;/P&gt;
&lt;P&gt;I have one question here.&lt;/P&gt;
&lt;P&gt;Regarding the macro quoted for a block of code having a block comment already, I am very impressed by it, but I am quite confuse about the sentence "&lt;SPAN&gt;Just make sure not to call the macro by mistake&lt;/SPAN&gt;", why I need to call the macro then?&lt;/P&gt;
&lt;P&gt;Because I jus ttry to run the code, and I see the code inside the macro even does not run (and that's great), so could you please explain why you note me about macro calling thingy?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=_w.vw_amihud noprint nway;
	class LOC year;
	var vw_amh;
	output out=agg_amihud_vw sum=agg_amh_vw;
run;
%macro skip_this;
/*
*method 1;
proc means data=agg_amihud_vw noprint nway;
	class LOC;
	var agg_amh_vw;
	output out=final_amihud mean=final_amh;
run;
*/

*method 2;
proc sql;
	create table new as 
	select LOC
		,mean(agg_amh_vw) as final_amh
	  from agg_amihud_vw
	  group by LOC
	;
run;
%mend skip_this;

proc means data=agg_amihud_vw noprint nway;
	class LOC;
	var agg_amh_vw;
	output out=final_amihud mean=final_amh;
	label agg_amh_vw=aggregate of vw_amh of all companies 
    in one year in one country ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And as can be seen from the log, the block of code inside the macro is not excuted&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;28         options mprint;
29         proc means data=_w.vw_amihud noprint nway;
30         	class LOC year;
31         	var vw_amh;
32         	output out=agg_amihud_vw sum=agg_amh_vw;
33         run;

NOTE: There were 9212 observations read from the data set _W.VW_AMIHUD.
NOTE: The data set WORK.AGG_AMIHUD_VW has 127 observations and 5 variables.
NOTE: Compressing data set WORK.AGG_AMIHUD_VW decreased size by 0.00 percent. 
      Compressed is 1 pages; un-compressed would require 1 pages.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      

34         %macro skip_this;
35         /*
36         *method 1;
37         proc means data=agg_amihud_vw noprint nway;
38         	class LOC;
39         	var agg_amh_vw;
40         	output out=final_amihud mean=final_amh;
41         run;
42         */
43         
44         *method 2;
45         proc sql;
46         	create table new as
47         	select LOC
48         		,mean(agg_amh_vw) as final_amh
49         	  from agg_amihud_vw
50         	  group by LOC
51         	;
52         run;
53         %mend skip_this;
54         
55         proc means data=agg_amihud_vw noprint nway;
56         	class LOC;
57         	var agg_amh_vw;
58         	output out=final_amihud mean=final_amh;
59         	label agg_amh_vw=aggregate of vw_amh of all companies
60             in one year in one country ;
61         run;

NOTE: There were 127 observations read from the data set WORK.AGG_AMIHUD_VW.
NOTE: The data set WORK.FINAL_AMIHUD has 43 observations and 4 variables.
NOTE: Compressing data set WORK.FINAL_AMIHUD decreased size by 0.00 percent. 
      Compressed is 1 pages; un-compressed would require 1 pages.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 07 Mar 2021 21:46:28 GMT</pubDate>
    <dc:creator>Phil_NZ</dc:creator>
    <dc:date>2021-03-07T21:46:28Z</dc:date>
    <item>
      <title>How to put a group of code to comment quickly ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724308#M224871</link>
      <description>&lt;P&gt;Hi all SAS Experts,&lt;/P&gt;
&lt;P&gt;Because I am learning SAS so normally, I want to know many types of solutions for one problem, that is why in my code, I always try to find some alternative ways to deal with a step.&lt;/P&gt;
&lt;P&gt;But it also comes with a cost that sometimes I do not know how to store my alternative solution quickly.&lt;/P&gt;
&lt;P&gt;For example, these two methods below generating the same result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*method 1;
proc means data=agg_amihud_vw noprint nway;
	class LOC;
	var agg_amh_vw;
	output out=final_amihud mean=final_amh;
run;

*method 2;
proc sql;
	create table new as 
	select LOC
		,mean(agg_amh_vw) as final_amh
	  from agg_amihud_vw
	  group by LOC
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And when I want to put method 2 to comment, I need to delete all the semicolon, which causes a lot of trouble when I want to call it again because sometimes I just forget to put the ";" somewhere, especially in case the alternative code is long&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*method 2
proc sql
	create table new as 
	select LOC
		,mean(agg_amh_vw) as final_amh
	  from agg_amihud_vw
	  group by LOC
	
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I know there are only three types of comment in SAS (*...; /* ....*/, and Comment....;). However, I want to ask your experience in storing the alternative method for one solution that I can learn from.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks and warmest regards.&lt;/P&gt;
&lt;P&gt;Have a good week!&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 20:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724308#M224871</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-07T20:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a group of code to comment quickly ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724311#M224874</link>
      <description>&lt;P&gt;In general block comments, &lt;FONT face="courier new,courier"&gt;/* .... */&lt;/FONT&gt;, work better to comment out pieces of code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
*method 1;
proc means data=agg_amihud_vw noprint nway;
	class LOC;
	var agg_amh_vw;
	output out=final_amihud mean=final_amh;
run;
*/

*method 2;
proc sql;
	create table new as 
	select LOC
		,mean(agg_amh_vw) as final_amh
	  from agg_amihud_vw
	  group by LOC
	;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Reserve the use of the statement comment,&amp;nbsp; &lt;FONT face="courier new,courier"&gt;* ... ;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;or the macro comment, &lt;FONT face="courier new,courier"&gt;%* ... ;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for entering comments that explain the code.&amp;nbsp;&amp;nbsp;The difference between the two is whether or not you want the comment to appear in the log when the MPRINT option is turned on.&amp;nbsp; So a comment that makes the log understandable you would use statement comment.&amp;nbsp; A comment that only someone editing the code would need to see then using a macro comment will keep the log clean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you ever need to comment out a block of code that already has block comments you can use a macro definition.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro skip_this;
/*
*method 1;
proc means data=agg_amihud_vw noprint nway;
	class LOC;
	var agg_amh_vw;
	output out=final_amihud mean=final_amh;
run;
*/

*method 2;
proc sql;
	create table new as 
	select LOC
		,mean(agg_amh_vw) as final_amh
	  from agg_amihud_vw
	  group by LOC
	;
run;
%mend skip_this;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Just make sure not to call the macro by mistake. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 21:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724311#M224874</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-07T21:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a group of code to comment quickly ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724313#M224875</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Amazing and hand-on suggestion, thank you very much.&lt;/P&gt;
&lt;P&gt;I have one question here.&lt;/P&gt;
&lt;P&gt;Regarding the macro quoted for a block of code having a block comment already, I am very impressed by it, but I am quite confuse about the sentence "&lt;SPAN&gt;Just make sure not to call the macro by mistake&lt;/SPAN&gt;", why I need to call the macro then?&lt;/P&gt;
&lt;P&gt;Because I jus ttry to run the code, and I see the code inside the macro even does not run (and that's great), so could you please explain why you note me about macro calling thingy?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=_w.vw_amihud noprint nway;
	class LOC year;
	var vw_amh;
	output out=agg_amihud_vw sum=agg_amh_vw;
run;
%macro skip_this;
/*
*method 1;
proc means data=agg_amihud_vw noprint nway;
	class LOC;
	var agg_amh_vw;
	output out=final_amihud mean=final_amh;
run;
*/

*method 2;
proc sql;
	create table new as 
	select LOC
		,mean(agg_amh_vw) as final_amh
	  from agg_amihud_vw
	  group by LOC
	;
run;
%mend skip_this;

proc means data=agg_amihud_vw noprint nway;
	class LOC;
	var agg_amh_vw;
	output out=final_amihud mean=final_amh;
	label agg_amh_vw=aggregate of vw_amh of all companies 
    in one year in one country ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And as can be seen from the log, the block of code inside the macro is not excuted&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;28         options mprint;
29         proc means data=_w.vw_amihud noprint nway;
30         	class LOC year;
31         	var vw_amh;
32         	output out=agg_amihud_vw sum=agg_amh_vw;
33         run;

NOTE: There were 9212 observations read from the data set _W.VW_AMIHUD.
NOTE: The data set WORK.AGG_AMIHUD_VW has 127 observations and 5 variables.
NOTE: Compressing data set WORK.AGG_AMIHUD_VW decreased size by 0.00 percent. 
      Compressed is 1 pages; un-compressed would require 1 pages.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      

34         %macro skip_this;
35         /*
36         *method 1;
37         proc means data=agg_amihud_vw noprint nway;
38         	class LOC;
39         	var agg_amh_vw;
40         	output out=final_amihud mean=final_amh;
41         run;
42         */
43         
44         *method 2;
45         proc sql;
46         	create table new as
47         	select LOC
48         		,mean(agg_amh_vw) as final_amh
49         	  from agg_amihud_vw
50         	  group by LOC
51         	;
52         run;
53         %mend skip_this;
54         
55         proc means data=agg_amihud_vw noprint nway;
56         	class LOC;
57         	var agg_amh_vw;
58         	output out=final_amihud mean=final_amh;
59         	label agg_amh_vw=aggregate of vw_amh of all companies
60             in one year in one country ;
61         run;

NOTE: There were 127 observations read from the data set WORK.AGG_AMIHUD_VW.
NOTE: The data set WORK.FINAL_AMIHUD has 43 observations and 4 variables.
NOTE: Compressing data set WORK.FINAL_AMIHUD decreased size by 0.00 percent. 
      Compressed is 1 pages; un-compressed would require 1 pages.
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 21:46:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724313#M224875</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-07T21:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a group of code to comment quickly ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724314#M224876</link>
      <description>&lt;P&gt;This is a trick, not a feature.&amp;nbsp; We are using the functionality of defining a macro to prevent the code from running.&amp;nbsp; But that means it actually has defined the macro.&amp;nbsp; So you could accidentally run this line of code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%skip_this;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which would call the macro that was defined and so run the code it contains.&amp;nbsp; Which would most likely be a mistake since you only created the macro to prevent the code from running.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 22:04:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724314#M224876</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-07T22:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to put a group of code to comment quickly ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724315#M224877</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is a mind-boggling trick to me, thank you for making my week. I am totally defeated by the beauty of the SAS code!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just a further cross-check: So you mean "do not call the macro by mistake" means that I just wrote the macro there, if I want to use this macro as a comment, just leave it as it is. If I want to execute the code inside this macro, I just type&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;%skip_this;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I hope and I believe that I understand what you mean correctly.&lt;/P&gt;
&lt;P&gt;Warmest regards.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Mar 2021 22:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-put-a-group-of-code-to-comment-quickly/m-p/724315#M224877</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-07T22:13:36Z</dc:date>
    </item>
  </channel>
</rss>

