<?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 Juletip #11 - SAS-code syntax coloring in macros and Warning free SQL joins using * in SAS Community Nordic</title>
    <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-11-SAS-code-syntax-coloring-in-macros-and-Warning-free/m-p/319038#M20</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know you are all waiting anxiously to receive the next tip; thus, you get it a little early - and it even contains two tips. So you can wait for tomorrow to read the second tip….&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Have you ever been annoyed by the fact that SAS-code is not syntax colored inside a macro?&lt;/STRONG&gt; I.e. the following (please copy and paste the code into EG or the Enhanced Editor, as the color highlighting in the embedded SAS-code is different from these):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro nocolor;
	data CLASS;
	set SASHELP.CLASS;
	run;
%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Enterprise Guide and the enhanced editor actually contains two “features” to enable the SAS-code syntax coloring. &lt;STRONG&gt;The first method&lt;/STRONG&gt; is to create an &lt;STRONG&gt;empty dummy macro&lt;/STRONG&gt; in the beginning of your real macro. If you end the dummy macro using the name, then the SAS-code syntax coloring magically appears. &lt;STRONG&gt;The second method&lt;/STRONG&gt; is to create a &lt;STRONG&gt;local macro variable, that you assign the value %nrstr(%mend)&lt;/STRONG&gt; – and yet again the SAS-code syntax coloring appears.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Examples on how to "enable" coloring of SAS Code inside macro */
%macro color; 
%* Empty dummy macro to enable syntax coloring;
	%macro bringBackColor; %mend bringBackColor; 
%* Normal SAS code with syntax coloring;
	data CLASS;
	set SASHELP.CLASS;
	run;
%mend;

%macro color2;
%* Local dummy variable to enable syntax coloring;
	%local a; %let a = %nrstr(%mend);   
%* Normal SAS code with syntax coloring;
	data CLASS;
	set SASHELP.CLASS;
	run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether these two ”features” continue&amp;nbsp;to exist in future releases of EG and the Enhanced Editor is uncertain, as it is referred to as unexpected behavior according to this: &lt;A href="http://support.sas.com/kb/34/953.html" target="_blank"&gt;http://support.sas.com/kb/34/953.html&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;However, for now you may get your SAS-code syntax coloring back in macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The second tip&lt;/STRONG&gt; is for all you lazy people (like myself) out there. When I do an &lt;STRONG&gt;SQL join&lt;/STRONG&gt; with two tables, where both tables uses the same name for the key variable, then &lt;STRONG&gt;I get a warning if I simply type select *&lt;/STRONG&gt;. In most cases, I am too lazy to write the names of all the columns in one of the tables, therefore I utilize &lt;STRONG&gt;SAS dataset options&lt;/STRONG&gt; to rename the key variable in one of the input tables and when appropriate drop the renamed variable in my output dataset. To be able to execute the example it requires you to download and extract the two attached SAS datasets to your SAS environment, and change the libname accordingly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname my_lib "C:\Temp";

/* Join with Warning */
proc sql;
	create table tmp as
	select *
	from  my_lib.order_fact a
		, my_lib.employee_organization b
	where
		a.employee_id=b.employee_id
	;
quit;
/* Join without Warning */
proc sql;
	create table tmp2(drop=emp_id) as
	select *
	from  my_lib.order_fact a
		, my_lib.employee_organization (rename=(employee_id=emp_id))b
	where
		a.employee_id=b.emp_id
	;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy Holidays!&lt;/P&gt;</description>
    <pubDate>Wed, 14 Dec 2016 20:31:52 GMT</pubDate>
    <dc:creator>CKjeldsen</dc:creator>
    <dc:date>2016-12-14T20:31:52Z</dc:date>
    <item>
      <title>Juletip #11 - SAS-code syntax coloring in macros and Warning free SQL joins using *</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-11-SAS-code-syntax-coloring-in-macros-and-Warning-free/m-p/319038#M20</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know you are all waiting anxiously to receive the next tip; thus, you get it a little early - and it even contains two tips. So you can wait for tomorrow to read the second tip….&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Have you ever been annoyed by the fact that SAS-code is not syntax colored inside a macro?&lt;/STRONG&gt; I.e. the following (please copy and paste the code into EG or the Enhanced Editor, as the color highlighting in the embedded SAS-code is different from these):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro nocolor;
	data CLASS;
	set SASHELP.CLASS;
	run;
%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Enterprise Guide and the enhanced editor actually contains two “features” to enable the SAS-code syntax coloring. &lt;STRONG&gt;The first method&lt;/STRONG&gt; is to create an &lt;STRONG&gt;empty dummy macro&lt;/STRONG&gt; in the beginning of your real macro. If you end the dummy macro using the name, then the SAS-code syntax coloring magically appears. &lt;STRONG&gt;The second method&lt;/STRONG&gt; is to create a &lt;STRONG&gt;local macro variable, that you assign the value %nrstr(%mend)&lt;/STRONG&gt; – and yet again the SAS-code syntax coloring appears.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Examples on how to "enable" coloring of SAS Code inside macro */
%macro color; 
%* Empty dummy macro to enable syntax coloring;
	%macro bringBackColor; %mend bringBackColor; 
%* Normal SAS code with syntax coloring;
	data CLASS;
	set SASHELP.CLASS;
	run;
%mend;

%macro color2;
%* Local dummy variable to enable syntax coloring;
	%local a; %let a = %nrstr(%mend);   
%* Normal SAS code with syntax coloring;
	data CLASS;
	set SASHELP.CLASS;
	run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whether these two ”features” continue&amp;nbsp;to exist in future releases of EG and the Enhanced Editor is uncertain, as it is referred to as unexpected behavior according to this: &lt;A href="http://support.sas.com/kb/34/953.html" target="_blank"&gt;http://support.sas.com/kb/34/953.html&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;However, for now you may get your SAS-code syntax coloring back in macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The second tip&lt;/STRONG&gt; is for all you lazy people (like myself) out there. When I do an &lt;STRONG&gt;SQL join&lt;/STRONG&gt; with two tables, where both tables uses the same name for the key variable, then &lt;STRONG&gt;I get a warning if I simply type select *&lt;/STRONG&gt;. In most cases, I am too lazy to write the names of all the columns in one of the tables, therefore I utilize &lt;STRONG&gt;SAS dataset options&lt;/STRONG&gt; to rename the key variable in one of the input tables and when appropriate drop the renamed variable in my output dataset. To be able to execute the example it requires you to download and extract the two attached SAS datasets to your SAS environment, and change the libname accordingly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname my_lib "C:\Temp";

/* Join with Warning */
proc sql;
	create table tmp as
	select *
	from  my_lib.order_fact a
		, my_lib.employee_organization b
	where
		a.employee_id=b.employee_id
	;
quit;
/* Join without Warning */
proc sql;
	create table tmp2(drop=emp_id) as
	select *
	from  my_lib.order_fact a
		, my_lib.employee_organization (rename=(employee_id=emp_id))b
	where
		a.employee_id=b.emp_id
	;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Happy Holidays!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2016 20:31:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-11-SAS-code-syntax-coloring-in-macros-and-Warning-free/m-p/319038#M20</guid>
      <dc:creator>CKjeldsen</dc:creator>
      <dc:date>2016-12-14T20:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Juletip #11 - SAS-code syntax coloring in macros and Warning free SQL joins using *</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-11-SAS-code-syntax-coloring-in-macros-and-Warning-free/m-p/694710#M298</link>
      <description>&lt;P&gt;This is a great solution, thanks for taking the time to share it.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 22:20:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-11-SAS-code-syntax-coloring-in-macros-and-Warning-free/m-p/694710#M298</guid>
      <dc:creator>dafata39</dc:creator>
      <dc:date>2020-10-27T22:20:33Z</dc:date>
    </item>
  </channel>
</rss>

