<?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: Macro within a Macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/735770#M229202</link>
    <description>Instead of this:&lt;BR /&gt;%LET Corner=&amp;amp;RoI/2; should be:&lt;BR /&gt;&lt;BR /&gt;Try:&lt;BR /&gt;%let corner =%sysevalf(&amp;amp;rol2/2);&lt;BR /&gt;&lt;BR /&gt;(or %EVAL, check the docs for the difference and see which makes sense for you)&lt;BR /&gt;&lt;BR /&gt;For macro questions you should also include your log, after having run your code with the MPRINT option on. This will show you how your macro variables are resolving and I'll bet that the second one shows that the corner variable is not resolving correctly.</description>
    <pubDate>Tue, 20 Apr 2021 20:36:02 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-04-20T20:36:02Z</dc:date>
    <item>
      <title>Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/735767#M229201</link>
      <description>&lt;P&gt;Esteemed Advisers:&lt;/P&gt;
&lt;P&gt;I'm having an issue with Macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code below runs two instances of a routine to draw a polygon.&lt;/P&gt;
&lt;P&gt;In Macro Test A, I use two macros statements. The first, &amp;amp;RoI, sets the size of Region of Interest and is used to reference the appropriate dataset. The second, &amp;amp;Corner, sets the locations of the corners of the RoI in the Annotation Dataset used to construct the polygon. The result (see attached pdf), shown as a plot labeled Macro Test A, displays the polygon as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In Macro Test B, I also use two macros, but in this case, &amp;amp;Corner is defined in terms of &amp;amp;RoI. The result (see attached pdf), shown in the plot labeled Macro Test B shows that the polygon is not drawn. Perhaps a macro can't reference another macro? If so, is there another way to automatically set the corners of the polygon from &amp;amp;RoI?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gee&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 TEST A*/
/*Create macro to select dataset for Region of Interest (work.test&amp;amp;RoI)*/
%LET RoI=460;
/*Create macro to locate corners of Region of Interest for polygon annotation*/
%LET Corner=230;
/*Annotation dataset for region of interest polygon*/
data anno_poly;
	length xc1 yc1 $10 function $50;
	linethickness=2;
	layer='front';
	x1space='datavalue';
	y1space='datavalue';
	function='polygon';
	xc1='-&amp;amp;Corner';
	yc1='-&amp;amp;Corner';
	output;
	function='polycont';
	xc1='&amp;amp;Corner';
	yc1='-&amp;amp;Corner';
	output;
	xc1='&amp;amp;Corner';
	yc1='&amp;amp;Corner';
	output;
	xc1='-&amp;amp;Corner';
	yc1='&amp;amp;Corner';
	output;
	data work.test&amp;amp;RoI;
	do ty=1 to 400 by 10;
	do tx=1 to 400 by 10;
	k=0;
	end;
	end;
	ods graphics / reset width=6.4in height=6.4in imagemap;
	proc sgplot data=work.test&amp;amp;RoI sganno=anno_poly aspect=1;
	title height=12pt "Macro Test A";
	heatmapparm x=tx y=ty colorgroup=k;
	xaxis label='KM' valuesrotate=vertical grid values=(-400 to 400 by 25) 
		fitpolicy=rotatethin;
	yaxis label='KM' grid values=(-400 to 400 by 25) fitpolicy=thin;
run;

/*MACRO TEST B*/
/*Create macro to select dataset for Region of Interest (work.test&amp;amp;RoI)*/
%LET RoI=460;
/*Create macro to locate corners of Region of Interest for polygon annotation*/
%LET Corner=&amp;amp;RoI/2;
/*Annotation dataset for region of interest polygon*/
data anno_poly;
	length xc1 yc1 $10 function $50;
	linethickness=2;
	layer='front';
	x1space='datavalue';
	y1space='datavalue';
	function='polygon';
	xc1='-&amp;amp;Corner';
	yc1='-&amp;amp;Corner';
	output;
	function='polycont';
	xc1='&amp;amp;Corner';
	yc1='-&amp;amp;Corner';
	output;
	xc1='&amp;amp;Corner';
	yc1='&amp;amp;Corner';
	output;
	xc1='-&amp;amp;Corner';
	yc1='&amp;amp;Corner';
	output;
	data work.test&amp;amp;roi;
	do ty=1 to 400 by 10;
	do tx=1 to 400 by 10;
	k=0;
	end;
	end;
	ods graphics / reset width=6.4in height=6.4in imagemap;
	proc sgplot data=work.test&amp;amp;roi sganno=anno_poly aspect=1;
	title height=12pt "Macro Test B";
	heatmapparm x=tx y=ty colorgroup=k;
	xaxis label='KM' valuesrotate=vertical grid values=(-400 to 400 by 25) 
		fitpolicy=rotatethin;
	yaxis label='KM' grid values=(-400 to 400 by 25) fitpolicy=thin;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Apr 2021 20:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/735767#M229201</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2021-04-20T20:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/735770#M229202</link>
      <description>Instead of this:&lt;BR /&gt;%LET Corner=&amp;amp;RoI/2; should be:&lt;BR /&gt;&lt;BR /&gt;Try:&lt;BR /&gt;%let corner =%sysevalf(&amp;amp;rol2/2);&lt;BR /&gt;&lt;BR /&gt;(or %EVAL, check the docs for the difference and see which makes sense for you)&lt;BR /&gt;&lt;BR /&gt;For macro questions you should also include your log, after having run your code with the MPRINT option on. This will show you how your macro variables are resolving and I'll bet that the second one shows that the corner variable is not resolving correctly.</description>
      <pubDate>Tue, 20 Apr 2021 20:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/735770#M229202</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-20T20:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/735771#M229203</link>
      <description>And as mentioned previously you're not using macros here, just macro variables. There is a significant difference. &lt;BR /&gt;Add this to the top of any program you're using with macro variables/macros to get more information in your log.&lt;BR /&gt;&lt;BR /&gt;options mprint symbolgen;</description>
      <pubDate>Tue, 20 Apr 2021 20:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/735771#M229203</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-20T20:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro within a Macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/735786#M229209</link>
      <description>Perfect!  Thanks so much!&lt;BR /&gt;&lt;BR /&gt;Gene</description>
      <pubDate>Tue, 20 Apr 2021 21:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-within-a-Macro/m-p/735786#M229209</guid>
      <dc:creator>genemroz</dc:creator>
      <dc:date>2021-04-20T21:10:02Z</dc:date>
    </item>
  </channel>
</rss>

