<?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: Resolving macro variables in SGPLOT titles or inset in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407355#M13916</link>
    <description>&lt;P&gt;&lt;SPAN class="login-bold"&gt;&lt;A id="link_8" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10604" target="_self"&gt;@djrisks&lt;/A&gt;&amp;nbsp;is correct that you can use %global.&amp;nbsp; You can also specify 'G' as the last argument to symputx.&amp;nbsp; Note that your question is about the scope of macro variables not about SGPLOT.&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2015/02/13/sas-macro-variables-how-to-determine-scope/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2015/02/13/sas-macro-variables-how-to-determine-scope/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2017 16:24:20 GMT</pubDate>
    <dc:creator>WarrenKuhfeld</dc:creator>
    <dc:date>2017-10-25T16:24:20Z</dc:date>
    <item>
      <title>Resolving macro variables in SGPLOT titles or inset</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407283#M13912</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to produce a series of KM plots which I'm writing in a macro using SGPLOT. I want to add the logrank p-value to each plot. Is there a way resolve marcro variables in the inset statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using call symputx I have assigned a macro variable &amp;amp;log_p to contain the relevant p-value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods listing gpath="&amp;amp;outpath\" image_dpi=300  style=tfl;
ods graphics / imagename="KM time to death ARM" reset=index height=5in width=6in;

proc sgplot data=survest1_e04brand noautolegend;
	step x=end_time y=survival / group=e04brand name="km";
	xaxis values=(0 to 56 by 7) label="Follow-up (Days)";
	yaxis values=(0 to 1 by 0.2) label="Probability of Survival";
	keylegend "km" / location=inside position=bottomright down=2 noborder;
	xaxistable atrisk / x=risk_time location=outside position=bottom class=e04brand title="N at Risk";
	inset "Log-Rank test P=&lt;STRONG&gt;&amp;amp;log_p&lt;/STRONG&gt;" / position=bottomleft;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, when I run this code I get the warning statement apparent symbolic reference not resolved and the text '&amp;amp;log_p' appears in the output graph rather than the value I would like it to resolve to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way around this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407283#M13912</guid>
      <dc:creator>DGrint</dc:creator>
      <dc:date>2017-10-25T14:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving macro variables in SGPLOT titles or inset</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407285#M13913</link>
      <description>&lt;P&gt;That will work if you generated the macro variable &amp;amp;log_p in the global symbol table.&amp;nbsp; Perhaps you have the wrong name?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:13:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407285#M13913</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-10-25T14:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving macro variables in SGPLOT titles or inset</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407297#M13914</link>
      <description>&lt;P&gt;The &amp;amp;log_p variable is generated in a datastep like so:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro km(...);&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;data _null_;
	set logrank;
	pval=round(probchisq,10**(-1*(abs(int(log10(abs(probchisq))))+2)));
	if test='Log-Rank' then call symputx('&lt;STRONG&gt;log_p&lt;/STRONG&gt;',pval);
run;
%put &amp;amp;log_p;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is that this data step is within a user defined macro, while I was testing the sgplot graph output outside. So the log_p macro was not global.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to make this log_p macro available globally even though it is defined with call symputx within the km user defined macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 14:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407297#M13914</guid>
      <dc:creator>DGrint</dc:creator>
      <dc:date>2017-10-25T14:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving macro variables in SGPLOT titles or inset</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407336#M13915</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you use the following?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro km(...);...

%global log_p;

data _null_;
set logrank;
pval=round(probchisq,10**(-1*(abs(int(log10(abs(probchisq))))+2)));
if test='Log-Rank' then call symputx('log_p',pval);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro km(...);...data test;
	set logrank;
	pval=round(probchisq,10**(-1*(abs(int(log10(abs(probchisq))))+2)));
	if test='Log-Rank';
run;

proc sql;
  select pval into :log_p
  from test;
quit;


%put &amp;amp;log_p;%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 15:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407336#M13915</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2017-10-25T15:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Resolving macro variables in SGPLOT titles or inset</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407355#M13916</link>
      <description>&lt;P&gt;&lt;SPAN class="login-bold"&gt;&lt;A id="link_8" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10604" target="_self"&gt;@djrisks&lt;/A&gt;&amp;nbsp;is correct that you can use %global.&amp;nbsp; You can also specify 'G' as the last argument to symputx.&amp;nbsp; Note that your question is about the scope of macro variables not about SGPLOT.&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sgf/2015/02/13/sas-macro-variables-how-to-determine-scope/" target="_blank"&gt;https://blogs.sas.com/content/sgf/2015/02/13/sas-macro-variables-how-to-determine-scope/&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2017 16:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Resolving-macro-variables-in-SGPLOT-titles-or-inset/m-p/407355#M13916</guid>
      <dc:creator>WarrenKuhfeld</dc:creator>
      <dc:date>2017-10-25T16:24:20Z</dc:date>
    </item>
  </channel>
</rss>

