<?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 Concatenation with macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-with-macro/m-p/260524#M50564</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this example what is the purpose of comma (",age,") in the concatenation function (cats).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mymacro(age=0);

	proc sql noprint;
		select quote(name) into :namelist separated by ',' 
           from sashelp.class where age=&amp;amp;age.;
	quit;

	data name_age;
		set sashelp.class;
		where name in (&amp;amp;namelist.);
	run;

	proc print data=name_age;
		var name age;
	run;

%mend mymacro;

proc sort data=sashelp.class out=class nodupkey;
	by age;
run;

data _null_;
	set class;
	exec_val = &lt;FONT color="#FF0000"&gt;cats('%mymacro(age=',age,')');&lt;/FONT&gt;
	call execute(exec_val);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Mar 2016 19:34:11 GMT</pubDate>
    <dc:creator>SAS_inquisitive</dc:creator>
    <dc:date>2016-03-31T19:34:11Z</dc:date>
    <item>
      <title>Concatenation with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-with-macro/m-p/260524#M50564</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this example what is the purpose of comma (",age,") in the concatenation function (cats).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mymacro(age=0);

	proc sql noprint;
		select quote(name) into :namelist separated by ',' 
           from sashelp.class where age=&amp;amp;age.;
	quit;

	data name_age;
		set sashelp.class;
		where name in (&amp;amp;namelist.);
	run;

	proc print data=name_age;
		var name age;
	run;

%mend mymacro;

proc sort data=sashelp.class out=class nodupkey;
	by age;
run;

data _null_;
	set class;
	exec_val = &lt;FONT color="#FF0000"&gt;cats('%mymacro(age=',age,')');&lt;/FONT&gt;
	call execute(exec_val);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 19:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-with-macro/m-p/260524#M50564</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-03-31T19:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenation with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-with-macro/m-p/260525#M50565</link>
      <description>&lt;P&gt;The comma separates the values that are to be concatenated. In this case the values are:&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;'%mymacro(age=&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;The value of the variable age&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;')'&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;to make a string that could be &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;%mymacro(age=23)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token string"&gt;as the call to the macro when the data _null_ step terminates.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 19:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-with-macro/m-p/260525#M50565</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-03-31T19:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenation with macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenation-with-macro/m-p/260639#M50619</link>
      <description>&lt;P&gt;Out of interest, why all the code? &amp;nbsp;It basically distills down to:&lt;/P&gt;
&lt;PRE&gt;proc sort data=sashelp.class out=class;
  by age;
run;
proc print data=class;
  by age;
run;&lt;/PRE&gt;
&lt;P&gt;Or worse case scenario:&lt;/P&gt;
&lt;PRE&gt;proc sort data=sashelp.class out=class nodupkey;
  by age;
run;&lt;BR /&gt;data _null_;&lt;BR /&gt;  set class;&lt;BR /&gt;  call execute(cat('proc print data=sashelp.class; where age=',strip(put(age,best.)),';run;');&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Apr 2016 08:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenation-with-macro/m-p/260639#M50619</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-01T08:38:26Z</dc:date>
    </item>
  </channel>
</rss>

