<?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: Apparent symbolic reference VARIABLE not resolved in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27401#M5015</link>
    <description>Hippo ,&lt;BR /&gt;
&lt;BR /&gt;
Macro arrays are arcian and out dated as much as past since they became popular.  The first data step is correct code for Version 8 Macro array creation, however if you are using V9 try using Call SymputX.&lt;BR /&gt;
&lt;BR /&gt;
The warnings you are getting are coming from the use of the macro variables you are creating in the first step.&lt;BR /&gt;
&lt;BR /&gt;
This:&lt;BR /&gt;
&lt;BR /&gt;
%SingleUpdate("&amp;amp;theID&amp;amp;i", "&amp;amp;theDesc&amp;amp;i");&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Should Be:&lt;BR /&gt;
&lt;BR /&gt;
%SingleUpdate("&amp;amp;&amp;amp;theID&amp;amp;i", "&amp;amp;&amp;amp;theDesc&amp;amp;i");&lt;BR /&gt;
&lt;BR /&gt;
Now beyond that tid bit Id have to see what the SingleUpDate macro code is to determine if it is even needed, the quotes are needed in the macro call, or even if the semi colon is needed.</description>
    <pubDate>Wed, 25 Jun 2008 21:34:24 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-06-25T21:34:24Z</dc:date>
    <item>
      <title>Apparent symbolic reference VARIABLE not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27395#M5009</link>
      <description>Hi guys&lt;BR /&gt;
I've created the arrays &lt;I&gt;theID&amp;amp;i&lt;/I&gt; and &lt;I&gt;theDesc&amp;amp;i&lt;/I&gt; and they works ok, but in addition, seems that SAS sees the variables with such names and says:&lt;BR /&gt;
WARNING: Apparent symbolic reference THEID not resolved.&lt;BR /&gt;
WARNING: Apparent symbolic reference THEDESC not resolved.&lt;BR /&gt;
Can't understand why, and how to avoid this warnings O_o&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;data null;&lt;BR /&gt;
   set work.logins end=eof;&lt;BR /&gt;
   call symput(compress('"theID"||put(_n_,best.))',trim(Id));&lt;BR /&gt;
   call symput(compress('"theDesc"||put(_n_,best.))',trim(Desc));&lt;BR /&gt;
   if eof then call symput('obscnt',put(_n_,best.));&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data null;&lt;BR /&gt;
   %do i=1 %to &amp;amp;obscnt;&lt;BR /&gt;
         %SingleUpdate("&amp;amp;theID&amp;amp;i", "&amp;amp;theDesc&amp;amp;i");&lt;BR /&gt;
   %end;        &lt;BR /&gt;
run;&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Tue, 24 Jun 2008 08:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27395#M5009</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-24T08:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference VARIABLE not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27396#M5010</link>
      <description>I think that the warnings are due to the fact that the macro processor while resolving the macro variables traverse from left to right. So in your case when it confronts &amp;amp;theID&amp;amp;i it sees it as (&amp;amp;theID)(&amp;amp;i), so while trying to resolve &amp;amp;theID it gives the warnings and resolves &amp;amp;i to it's numeric value. On the next pass it gets &amp;amp;theiD1 (say when &amp;amp;i resloves to 1) and correctly resloves it.&lt;BR /&gt;
&lt;BR /&gt;
So the way to avoid the warnings will be to code in such a way that &amp;amp;i is resolved first and then &amp;amp;theID&amp;lt;&amp;gt; is resolved.</description>
      <pubDate>Tue, 24 Jun 2008 09:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27396#M5010</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-24T09:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference VARIABLE not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27397#M5011</link>
      <description>&amp;gt; So the way to avoid the warnings will be to code in such a way that &amp;amp;i is resolved first and then &amp;amp;theID is resolved.&lt;BR /&gt;
&lt;BR /&gt;
I am not sure that the problem appears in &lt;I&gt;&amp;amp;i&lt;/I&gt;, because &lt;I&gt;&amp;amp;i&lt;/I&gt; uses later. Seems that problem appears in &lt;I&gt;_n_&lt;/I&gt;. But I still have no idea how to avoid it O_o</description>
      <pubDate>Tue, 24 Jun 2008 13:11:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27397#M5011</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-24T13:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference VARIABLE not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27398#M5012</link>
      <description>Are you sure that you are getting exactly what you want?  I may have missed something but your data _null_ module should have double&amp;amp;. That should cure your warning message. &lt;BR /&gt;
&lt;BR /&gt;
In your example the macro processor replaces the &amp;amp;i and the &amp;amp;theID at the "same time" so SAS is looking for &amp;amp;i which it can find but it can't find &amp;amp;theID b/c it doesn't exist.  With a double ampersand, SAS resolves the &amp;amp;&amp;amp; to a single &amp;amp;.  So when the macro facility sees &amp;amp;&amp;amp;theID&amp;amp;i, the first iteration will look like &amp;amp;theID1 then &amp;amp;theID1 gets resolved.  Cynthia and others on this site have offered much more elegant explainations.&lt;BR /&gt;
&lt;BR /&gt;
See my examples&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Try this:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
%do i=1 %to &amp;amp;obscnt;&lt;BR /&gt;
%SingleUpdate("&amp;amp;&amp;amp;theID&amp;amp;i", "&amp;amp;&amp;amp;theDesc&amp;amp;i");&lt;BR /&gt;
%end; &lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
See my example to show how the &amp;amp;&amp;amp; and &amp;amp; resolve&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input id desc $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 NORTH&lt;BR /&gt;
2 SOUTH&lt;BR /&gt;
3 EAST&lt;BR /&gt;
4 WEST&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%macro test_macro;&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  set test end=eof;&lt;BR /&gt;
  call symput('theID'||strip(put(_n_,best.)),strip(put(id,best.)));&lt;BR /&gt;
  call symput('theDESC'||strip(put(_n_,best.)),strip(desc));&lt;BR /&gt;
  if eof then call symput ('obscnt',strip(put(_n_,best.)));&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select *&lt;BR /&gt;
    from dictionary.macros&lt;BR /&gt;
	where name like 'THEID%' or name like 'THEDESC%' or name eq 'OBSCNT';&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
  %put Will Generate a Warning;&lt;BR /&gt;
  %do i=1 %to &amp;amp;obscnt;&lt;BR /&gt;
    %put  '&amp;amp;theID&amp;amp;i'=&amp;amp;theID&amp;amp;i '&amp;amp;theDESC&amp;amp;i'=&amp;amp;theDESC&amp;amp;i;&lt;BR /&gt;
  %end;&lt;BR /&gt;
  %put;&lt;BR /&gt;
  %put Will Not Generate a Warning;&lt;BR /&gt;
  %do i=1 %to &amp;amp;obscnt;&lt;BR /&gt;
    %put  '&amp;amp;&amp;amp;theID&amp;amp;i'=&amp;amp;&amp;amp;theID&amp;amp;i '&amp;amp;&amp;amp;theDESC&amp;amp;i'=&amp;amp;&amp;amp;theDESC&amp;amp;i;&lt;BR /&gt;
  %end;&lt;BR /&gt;
    &lt;BR /&gt;
&lt;BR /&gt;
%mend test_macro;&lt;BR /&gt;
%test_macro;&lt;BR /&gt;
&lt;BR /&gt;
-Regards/&lt;BR /&gt;
Darryl</description>
      <pubDate>Tue, 24 Jun 2008 13:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27398#M5012</guid>
      <dc:creator>darrylovia</dc:creator>
      <dc:date>2008-06-24T13:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference VARIABLE not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27399#M5013</link>
      <description>This may be over simplifiying the problem but you don't need to use the single quotes around the entire name  ie... '"theID"||put(_n_,best.))'.  You only need the quotes around "theID".</description>
      <pubDate>Tue, 24 Jun 2008 14:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27399#M5013</guid>
      <dc:creator>LAP</dc:creator>
      <dc:date>2008-06-24T14:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference VARIABLE not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27400#M5014</link>
      <description>Okay, let's use more efficient functions. Say, the test data was generated as&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
	do i=1 to 10;&lt;BR /&gt;
		id = int(ranuni(0)*1000 + 0.5);&lt;BR /&gt;
		desc = int(ranuni(0)*20 + 0.5);&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
	drop i;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Then your codes&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
	set test end=eof;&lt;BR /&gt;
	call symput('theID'||strip(put(_n_,best.)),strip(put(id,best.)));&lt;BR /&gt;
	call symput('theDESC'||strip(put(_n_,best.)),strip(desc));&lt;BR /&gt;
	if eof then call symput ('obscnt',strip(put(_n_,best.)));&lt;BR /&gt;
run;&lt;BR /&gt;
%put _user_;&lt;BR /&gt;
&lt;BR /&gt;
Nothing wrong, but too fuzzy with quotes. How about with the new functions?&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
	set test end=eof;&lt;BR /&gt;
	call &lt;B&gt;&lt;I&gt;symputx&lt;/I&gt;&lt;/B&gt;(&lt;I&gt;&lt;B&gt;catt&lt;/B&gt;&lt;/I&gt;('theID', _n_), id);&lt;BR /&gt;
	call symputx(catt('theDESC', _n_), desc);&lt;BR /&gt;
	if eof then call symputx('obscnt', _n_);&lt;BR /&gt;
run;&lt;BR /&gt;
%put _user_;&lt;BR /&gt;
&lt;BR /&gt;
Same macro variables, but no more &lt;BR /&gt;
&lt;I&gt;&lt;B&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;BR /&gt;
      927:54&lt;/B&gt;&lt;/I&gt;&lt;BR /&gt;
&lt;BR /&gt;
&lt;U&gt;&lt;I&gt;&lt;B&gt;You don't need to use ||, ", ', best, strip, trim, etc.&lt;BR /&gt;
symputx, catt, catx, etc are efficient functions and more general&lt;/B&gt;&lt;/I&gt;&lt;/U&gt;</description>
      <pubDate>Tue, 24 Jun 2008 20:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27400#M5014</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-24T20:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent symbolic reference VARIABLE not resolved</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27401#M5015</link>
      <description>Hippo ,&lt;BR /&gt;
&lt;BR /&gt;
Macro arrays are arcian and out dated as much as past since they became popular.  The first data step is correct code for Version 8 Macro array creation, however if you are using V9 try using Call SymputX.&lt;BR /&gt;
&lt;BR /&gt;
The warnings you are getting are coming from the use of the macro variables you are creating in the first step.&lt;BR /&gt;
&lt;BR /&gt;
This:&lt;BR /&gt;
&lt;BR /&gt;
%SingleUpdate("&amp;amp;theID&amp;amp;i", "&amp;amp;theDesc&amp;amp;i");&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Should Be:&lt;BR /&gt;
&lt;BR /&gt;
%SingleUpdate("&amp;amp;&amp;amp;theID&amp;amp;i", "&amp;amp;&amp;amp;theDesc&amp;amp;i");&lt;BR /&gt;
&lt;BR /&gt;
Now beyond that tid bit Id have to see what the SingleUpDate macro code is to determine if it is even needed, the quotes are needed in the macro call, or even if the semi colon is needed.</description>
      <pubDate>Wed, 25 Jun 2008 21:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-symbolic-reference-VARIABLE-not-resolved/m-p/27401#M5015</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-25T21:34:24Z</dc:date>
    </item>
  </channel>
</rss>

