<?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 Naming Macro Variable Within A Macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568593#M11690</link>
    <description>&lt;P&gt;Version 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SAS source code contains several equations and each&amp;nbsp;is numbered.&amp;nbsp; The macro CountPrimaryResults counts the number of observations&amp;nbsp;that are Primary.&amp;nbsp; It&amp;nbsp;has parameters of inputdataset, outputdataset, and equation_number.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro CountPrimaryResults(inputdataset=,outputdataset=,equation_number=);

proc sql;
		create table work.&amp;amp;outputdataset as
		select Constituent_Name, count(Constituent_Name) as PrimaryResultsCount
		from work.&amp;amp;inputdataset
		where Result_Type in ('PRIMARY_RESULT') 
		group by Constituent_Name;
quit;

data work.&amp;amp;outputdataset;
	set work.&amp;amp;outputdataset end=eof;
	retain flag 0;
	if PrimaryResultsCount le 5 then do;
			Warning=Constituent_Name;
			flag=1;
		end;
	if eof and flag=1 then call symputx('check','failed'); 
		else call symputx('check','passed');
run;
%put &amp;amp;check;

%mend CountPrimaryResults;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like to create a global macro within CountPrimaryResults that has "passed" or "failed" with the equation number as a part of the macro variable created within symputx.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For equation 7, the call to the macro was:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

%CountPrimaryResults(inputdataset=feedunitdose,outputdataset=countfeedunitdose,equation_number=7);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;I want a global macro check7 with the result of "passed" or "failed".&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;This is what I tried:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro CountPrimaryResults(inputdataset=,outputdataset=,equation_number=);

proc sql;
		create table work.&amp;amp;outputdataset as
		select Constituent_Name, count(Constituent_Name) as PrimaryResultsCount
		from work.&amp;amp;inputdataset
		where Result_Type in ('PRIMARY_RESULT') 
		group by Constituent_Name;
quit;

data work.&amp;amp;outputdataset;
	set work.&amp;amp;outputdataset end=eof;
	retain flag 0;
	if PrimaryResultsCount le 5 then do;
			Warning=Constituent_Name;
			flag=1;
		end;
	if eof and flag=1 then call symputx('chk&amp;amp;equation_number','failed'); 
		else call symputx('chk&amp;amp;equation_number','passed');
run;
%put &amp;amp;chk&amp;amp;equation_number;

%mend CountPrimaryResults;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The warning message reads:&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference CHK not resolved.&lt;/P&gt;&lt;P&gt;&amp;amp;chk7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but reference to %put &amp;amp;chk7 also doesn't work (echos &amp;amp;chk7)&amp;nbsp;within or outside the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jun 2019 22:26:41 GMT</pubDate>
    <dc:creator>jawhitmire</dc:creator>
    <dc:date>2019-06-24T22:26:41Z</dc:date>
    <item>
      <title>Naming Macro Variable Within A Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568593#M11690</link>
      <description>&lt;P&gt;Version 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SAS source code contains several equations and each&amp;nbsp;is numbered.&amp;nbsp; The macro CountPrimaryResults counts the number of observations&amp;nbsp;that are Primary.&amp;nbsp; It&amp;nbsp;has parameters of inputdataset, outputdataset, and equation_number.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro CountPrimaryResults(inputdataset=,outputdataset=,equation_number=);

proc sql;
		create table work.&amp;amp;outputdataset as
		select Constituent_Name, count(Constituent_Name) as PrimaryResultsCount
		from work.&amp;amp;inputdataset
		where Result_Type in ('PRIMARY_RESULT') 
		group by Constituent_Name;
quit;

data work.&amp;amp;outputdataset;
	set work.&amp;amp;outputdataset end=eof;
	retain flag 0;
	if PrimaryResultsCount le 5 then do;
			Warning=Constituent_Name;
			flag=1;
		end;
	if eof and flag=1 then call symputx('check','failed'); 
		else call symputx('check','passed');
run;
%put &amp;amp;check;

%mend CountPrimaryResults;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like to create a global macro within CountPrimaryResults that has "passed" or "failed" with the equation number as a part of the macro variable created within symputx.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For equation 7, the call to the macro was:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

%CountPrimaryResults(inputdataset=feedunitdose,outputdataset=countfeedunitdose,equation_number=7);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;I want a global macro check7 with the result of "passed" or "failed".&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;This is what I tried:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro CountPrimaryResults(inputdataset=,outputdataset=,equation_number=);

proc sql;
		create table work.&amp;amp;outputdataset as
		select Constituent_Name, count(Constituent_Name) as PrimaryResultsCount
		from work.&amp;amp;inputdataset
		where Result_Type in ('PRIMARY_RESULT') 
		group by Constituent_Name;
quit;

data work.&amp;amp;outputdataset;
	set work.&amp;amp;outputdataset end=eof;
	retain flag 0;
	if PrimaryResultsCount le 5 then do;
			Warning=Constituent_Name;
			flag=1;
		end;
	if eof and flag=1 then call symputx('chk&amp;amp;equation_number','failed'); 
		else call symputx('chk&amp;amp;equation_number','passed');
run;
%put &amp;amp;chk&amp;amp;equation_number;

%mend CountPrimaryResults;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The warning message reads:&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference CHK not resolved.&lt;/P&gt;&lt;P&gt;&amp;amp;chk7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but reference to %put &amp;amp;chk7 also doesn't work (echos &amp;amp;chk7)&amp;nbsp;within or outside the macro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 22:26:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568593#M11690</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-06-24T22:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Naming Macro Variable Within A Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568598#M11691</link>
      <description>&lt;P&gt;Macro triggers are not resolved inside single quotes.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 22:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568598#M11691</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-24T22:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Naming Macro Variable Within A Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568603#M11693</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro CountPrimaryResults(inputdataset=,outputdataset=,equation_number=);

proc sql;
		create table work.&amp;amp;outputdataset as
		select Constituent_Name, count(Constituent_Name) as PrimaryResultsCount
		from work.&amp;amp;inputdataset
		where Result_Type in ('PRIMARY_RESULT') 
		group by Constituent_Name;
quit;

data work.&amp;amp;outputdataset;
	set work.&amp;amp;outputdataset end=eof;
	retain flag 0;
	if PrimaryResultsCount le 5 then do;
			Warning=Constituent_Name;
			flag=1;
		end;
	if eof and flag=1 then call symputx("chk&amp;amp;equation_number","failed"); 
		else call symputx("chk&amp;amp;equation_number","passed");
run;
%put "&amp;amp;chk&amp;amp;equation_number";

%mend CountPrimaryResults;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Call...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%CountPrimaryResults(inputdataset=feedunitdose,outputdataset=countfeedunitdose,equation_number=7);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;leads to WARNING message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference CHK not resolved.&lt;/P&gt;&lt;P&gt;"passed"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any way to get rid of the warning?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 22:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568603#M11693</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-06-24T22:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Naming Macro Variable Within A Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568605#M11694</link>
      <description>&lt;P&gt;Instead of &amp;amp;chk&amp;amp;equation_number try&lt;/P&gt;
&lt;P&gt;&amp;amp;&amp;amp;chk&amp;amp;equation_number&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your %put statement.&lt;/P&gt;
&lt;P&gt;If you want quotes in the value of the macro variable use the QUOTE function in the call symputx&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro dummy(eqno=);
   data _null_;
     call symputx("chk&amp;amp;eqno.",quote("failed"));
   run;

%put &amp;amp;&amp;amp;chk&amp;amp;eqno.;
%mend;
%dummy(eqno=5)
&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jun 2019 22:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568605#M11694</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-24T22:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Naming Macro Variable Within A Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568606#M11695</link>
      <description>&lt;P&gt;For the indirect reference, use a double ampersand:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put "&amp;amp;&amp;amp;chk&amp;amp;equation_number";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jun 2019 23:00:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568606#M11695</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-24T23:00:19Z</dc:date>
    </item>
    <item>
      <title>Re: Naming Macro Variable Within A Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568608#M11696</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Who would of thought it was so simple?&amp;nbsp; I guess the double ampersands is to force the reading of the first macro variable as separate from the second macro variable name -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 23:03:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568608#M11696</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-06-24T23:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: Naming Macro Variable Within A Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568615#M11698</link>
      <description>&lt;P&gt;The double ampersand forces two passes; in the first pass, the double ampersand is resolved to a single one, and macro variables within the string are resolved; in the second pass, the whole construct is resolved. This method can be expanded by using even more consecutive ampersands.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 23:37:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568615#M11698</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-24T23:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Naming Macro Variable Within A Macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568771#M11716</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The double ampersand forces two passes; in the first pass, the double ampersand is resolved to a single one, and macro variables within the string are resolved; in the second pass, the whole construct is resolved. This method can be expanded by using even more consecutive ampersands.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And ever more obscure code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes I've done that. And now look for alternate approaches as if I don't look at the code for awhile I don't remember why &amp;amp;&amp;amp;&amp;amp;&amp;amp;This&amp;amp;&amp;amp;var&amp;amp;mess was a good idea.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 13:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Naming-Macro-Variable-Within-A-Macro/m-p/568771#M11716</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-25T13:50:19Z</dc:date>
    </item>
  </channel>
</rss>

