<?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: WARNING: Apparent symbolic reference TERMS_ID not resolved. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/WARNING-Apparent-symbolic-reference-TERMS-ID-not-resolved/m-p/776004#M246707</link>
    <description>&lt;P&gt;You have declared the macro variable Term_id to be a %local variable in the macro Do_all. So as soon as the macro portion of the code quits running that macro variable no longer exists. So it cannot be referenced outside of the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to say that your "Do_all" is a good candidate for most useless macro of the week. It really performs no task and if you had declared the macro variable Terms_id to be global I still don't see much use for it unless the purpose is to get the last item of a list in an inefficient way.&lt;/P&gt;
&lt;P&gt;Here's an example with Term_id actually %global:&lt;/P&gt;
&lt;PRE&gt;%macro do_all(termlist);
	%local i;
   %global Terms_id;

	%do i=1 %to %sysfunc(countw(&amp;amp;termlist,%str( ) ));
		%let TERMS_ID=%scan(&amp;amp;termlist,&amp;amp;i,%str( ));
	%end;
%mend do_all;

%do_all(2017SU 2017FA 2018SP 2018SU 2018FA 2019SP 2019SU 2019FA
	2020SP 2020SU 2020FA 2021SP 2021SU 2021FA)

%put The value of Terms_id is: &amp;amp;terms_id.;
&lt;/PRE&gt;
&lt;P&gt;And if you put that Proc SQL code inside the loop from Do_all you would still only create one data set, One_term, overwriting multiple times until it contains the values from the last item in that list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/145106"&gt;@cmshearon8845&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;This is the first time I'm trying a global macro in a code. I thought I referenced the macro variables in the code, but I'm not sure. I'm not sure what I'm doing wrong. Here is my macro statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;options symbolgen;

%macro do_all(termlist);
	%local i TERMS_ID;

	%do i=1 %to %sysfunc(countw(&amp;amp;termlist,%str( ) ));
		%let TERMS_ID=%scan(&amp;amp;termlist,&amp;amp;i,%str( ));
	%end;
%mend do_all;

%do_all(2017SU 2017FA 2018SP 2018SU 2018FA 2019SP 2019SU 2019FA
	2020SP 2020SU 2020FA 2021SP 2021SU 2021FA)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the part of the code with the macro variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
	create table OneTerm as
		select drv.TERMS_ID,drv.day,(drv.day+drv.start_dt) as date format
			yymmdd10.,drv.Section_Name,
		case 
			when a.CreditHours is missing then 0 
			else a.CreditHours 
		end 
	as CreditHours,
		case 
			when a.SeatCount is missing then 0 
			else a.Seatcount 
		end 
	as Seatcount
		from(select distinct a.Terms_ID,a.day,(a.date-a.day) as start_dt format
			yymmdd10.,b.Section_Name
		from work.AddRegDay as a
			left join
				(select distinct TERMS_ID, Section_Name from work.AddRegDay where TERMS_ID = "&amp;amp;terms_id"
					and Section_Name is not null) b
					on a.TERMS_ID=b.TERMS_ID
				where a.TERMS_ID = "&amp;amp;terms_id") as drv
					left join
						(select * from work.AddRegDay where Terms_ID = "&amp;amp;terms_id") as a
							on drv.day=a.day and drv.Section_Name=a.Section_Name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm also attaching the logs from Symbolgen options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 23 Oct 2021 05:31:26 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-10-23T05:31:26Z</dc:date>
    <item>
      <title>WARNING: Apparent symbolic reference TERMS_ID not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-Apparent-symbolic-reference-TERMS-ID-not-resolved/m-p/776002#M246705</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;This is the first time I'm trying a global macro in a code. I thought I referenced the macro variables in the code, but I'm not sure. I'm not sure what I'm doing wrong. Here is my macro statement:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;options symbolgen;

%macro do_all(termlist);
	%local i TERMS_ID;

	%do i=1 %to %sysfunc(countw(&amp;amp;termlist,%str( ) ));
		%let TERMS_ID=%scan(&amp;amp;termlist,&amp;amp;i,%str( ));
	%end;
%mend do_all;

%do_all(2017SU 2017FA 2018SP 2018SU 2018FA 2019SP 2019SU 2019FA
	2020SP 2020SU 2020FA 2021SP 2021SU 2021FA)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the part of the code with the macro variable:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
	create table OneTerm as
		select drv.TERMS_ID,drv.day,(drv.day+drv.start_dt) as date format
			yymmdd10.,drv.Section_Name,
		case 
			when a.CreditHours is missing then 0 
			else a.CreditHours 
		end 
	as CreditHours,
		case 
			when a.SeatCount is missing then 0 
			else a.Seatcount 
		end 
	as Seatcount
		from(select distinct a.Terms_ID,a.day,(a.date-a.day) as start_dt format
			yymmdd10.,b.Section_Name
		from work.AddRegDay as a
			left join
				(select distinct TERMS_ID, Section_Name from work.AddRegDay where TERMS_ID = "&amp;amp;terms_id"
					and Section_Name is not null) b
					on a.TERMS_ID=b.TERMS_ID
				where a.TERMS_ID = "&amp;amp;terms_id") as drv
					left join
						(select * from work.AddRegDay where Terms_ID = "&amp;amp;terms_id") as a
							on drv.day=a.day and drv.Section_Name=a.Section_Name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm also attaching the logs from Symbolgen options.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 04:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-Apparent-symbolic-reference-TERMS-ID-not-resolved/m-p/776002#M246705</guid>
      <dc:creator>cmshearon8845</dc:creator>
      <dc:date>2021-10-23T04:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: WARNING: Apparent symbolic reference TERMS_ID not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-Apparent-symbolic-reference-TERMS-ID-not-resolved/m-p/776004#M246707</link>
      <description>&lt;P&gt;You have declared the macro variable Term_id to be a %local variable in the macro Do_all. So as soon as the macro portion of the code quits running that macro variable no longer exists. So it cannot be referenced outside of the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to say that your "Do_all" is a good candidate for most useless macro of the week. It really performs no task and if you had declared the macro variable Terms_id to be global I still don't see much use for it unless the purpose is to get the last item of a list in an inefficient way.&lt;/P&gt;
&lt;P&gt;Here's an example with Term_id actually %global:&lt;/P&gt;
&lt;PRE&gt;%macro do_all(termlist);
	%local i;
   %global Terms_id;

	%do i=1 %to %sysfunc(countw(&amp;amp;termlist,%str( ) ));
		%let TERMS_ID=%scan(&amp;amp;termlist,&amp;amp;i,%str( ));
	%end;
%mend do_all;

%do_all(2017SU 2017FA 2018SP 2018SU 2018FA 2019SP 2019SU 2019FA
	2020SP 2020SU 2020FA 2021SP 2021SU 2021FA)

%put The value of Terms_id is: &amp;amp;terms_id.;
&lt;/PRE&gt;
&lt;P&gt;And if you put that Proc SQL code inside the loop from Do_all you would still only create one data set, One_term, overwriting multiple times until it contains the values from the last item in that list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/145106"&gt;@cmshearon8845&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;This is the first time I'm trying a global macro in a code. I thought I referenced the macro variables in the code, but I'm not sure. I'm not sure what I'm doing wrong. Here is my macro statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;options symbolgen;

%macro do_all(termlist);
	%local i TERMS_ID;

	%do i=1 %to %sysfunc(countw(&amp;amp;termlist,%str( ) ));
		%let TERMS_ID=%scan(&amp;amp;termlist,&amp;amp;i,%str( ));
	%end;
%mend do_all;

%do_all(2017SU 2017FA 2018SP 2018SU 2018FA 2019SP 2019SU 2019FA
	2020SP 2020SU 2020FA 2021SP 2021SU 2021FA)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the part of the code with the macro variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
	create table OneTerm as
		select drv.TERMS_ID,drv.day,(drv.day+drv.start_dt) as date format
			yymmdd10.,drv.Section_Name,
		case 
			when a.CreditHours is missing then 0 
			else a.CreditHours 
		end 
	as CreditHours,
		case 
			when a.SeatCount is missing then 0 
			else a.Seatcount 
		end 
	as Seatcount
		from(select distinct a.Terms_ID,a.day,(a.date-a.day) as start_dt format
			yymmdd10.,b.Section_Name
		from work.AddRegDay as a
			left join
				(select distinct TERMS_ID, Section_Name from work.AddRegDay where TERMS_ID = "&amp;amp;terms_id"
					and Section_Name is not null) b
					on a.TERMS_ID=b.TERMS_ID
				where a.TERMS_ID = "&amp;amp;terms_id") as drv
					left join
						(select * from work.AddRegDay where Terms_ID = "&amp;amp;terms_id") as a
							on drv.day=a.day and drv.Section_Name=a.Section_Name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm also attaching the logs from Symbolgen options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 05:31:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-Apparent-symbolic-reference-TERMS-ID-not-resolved/m-p/776004#M246707</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-23T05:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: WARNING: Apparent symbolic reference TERMS_ID not resolved.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-Apparent-symbolic-reference-TERMS-ID-not-resolved/m-p/776007#M246710</link>
      <description>&lt;P&gt;Your macro call can be replaced by&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let terms_id=2021FA;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as it does nothing else.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Oct 2021 05:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-Apparent-symbolic-reference-TERMS-ID-not-resolved/m-p/776007#M246710</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-23T05:48:35Z</dc:date>
    </item>
  </channel>
</rss>

