<?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 (Warning:apparent symbol not resolved) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125703#M34552</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys for your reply,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dear Patrick, several questions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the difference of using a) or b),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this b) option could work in my code also?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;a)if &amp;amp;n=1 then call symput("record1",records);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;b)%if &amp;amp;n=1 %then &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;call symput("record1",records);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thanks in advance,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;V.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Oct 2013 09:44:00 GMT</pubDate>
    <dc:creator>michtka</dc:creator>
    <dc:date>2013-10-28T09:44:00Z</dc:date>
    <item>
      <title>macro (Warning:apparent symbol not resolved)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125698#M34547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, I have the next error message in this code:&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference RECORD1 not resolved.&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference RECORD2 not resolved.&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference RECORD3 not resolved.&lt;/P&gt;&lt;P&gt;WARNING: Apparent symbolic reference RECORD4 not resolved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you tell me what I am doing wrong? Thanks. V&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;****piece of code;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input records;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro test(n=);&lt;/P&gt;&lt;P&gt;data&amp;nbsp; want&amp;amp;n.;&lt;/P&gt;&lt;P&gt;set have (obs=&amp;amp;n.);&lt;/P&gt;&lt;P&gt;if n=1 then call symput("record1",records);&lt;/P&gt;&lt;P&gt;if n=2 then call symput("record2",records);&lt;/P&gt;&lt;P&gt;if n=3 then call symput("record3",records);&lt;/P&gt;&lt;P&gt;if n=4 then call symput("record4",records);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test(n=1);&lt;/P&gt;&lt;P&gt;%test(n=2);&lt;/P&gt;&lt;P&gt;%test(n=3);&lt;/P&gt;&lt;P&gt;%test(n=4);&lt;/P&gt;&lt;P&gt;%put &amp;amp;record1 &amp;amp;record2 &amp;amp;record3 &amp;amp;record4;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 03:42:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125698#M34547</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2013-10-28T03:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: macro (Warning:apparent symbol not resolved)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125699#M34548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Sorry, my mistake....but still does not work...any help? Thanks.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if &amp;amp;n.=1 then call symput("record1",records);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if &amp;amp;n.=2 then call symput("record2",records);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if &amp;amp;n.=3 then call symput("record3",records);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if &amp;amp;n.=4 then call symput("record4",records);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 03:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125699#M34548</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2013-10-28T03:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: macro (Warning:apparent symbol not resolved)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125700#M34549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You create the macro variables within a&amp;nbsp; macro and so they have a scope of local.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to add the following inside your macro:&lt;/P&gt;&lt;P&gt;%global &amp;amp;record1 &amp;amp;record2 &amp;amp;record3 &amp;amp;record4;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would also add a %let statement to initialise the macro vars so that you don't have "left over" populated macro vars from previous runs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I understand correctly what you're trying to do then you should also use "&amp;amp;n" instead of "n" in your if condition.&lt;/P&gt;&lt;P&gt;if &amp;amp;n=1 then call symput("record1",records);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...and as only one of the conditions will be true you should also use an else:&lt;/P&gt;&lt;P&gt;if &amp;amp;n=1 then call symput("record1",records);&lt;/P&gt;&lt;P&gt;else if &amp;amp;n=2 then call symput("record2",records);&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 03:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125700#M34549</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-10-28T03:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: macro (Warning:apparent symbol not resolved)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125701#M34550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input records;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;options symbolgen mprint mlogic;&lt;/P&gt;&lt;P&gt;%macro test(n=);&lt;/P&gt;&lt;P&gt;%global record&amp;amp;n.;&lt;/P&gt;&lt;P&gt;data&amp;nbsp; want&amp;amp;n.;&lt;/P&gt;&lt;P&gt;set have (firstobs=&amp;amp;n. obs=&amp;amp;n.);&lt;/P&gt;&lt;P&gt;call symputx("record"||left(put(&amp;amp;n.,2.)),records);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test(n=1);&lt;/P&gt;&lt;P&gt;%test(n=2);&lt;/P&gt;&lt;P&gt;%test(n=3);&lt;/P&gt;&lt;P&gt;%test(n=4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;record1 &amp;amp;record2 &amp;amp;record3 &amp;amp;record4 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 06:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125701#M34550</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2013-10-28T06:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: macro (Warning:apparent symbol not resolved)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125702#M34551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Answer already provided in my initial post. Read it all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 06:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125702#M34551</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-10-28T06:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: macro (Warning:apparent symbol not resolved)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125703#M34552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks guys for your reply,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dear Patrick, several questions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the difference of using a) or b),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this b) option could work in my code also?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;a)if &amp;amp;n=1 then call symput("record1",records);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;b)%if &amp;amp;n=1 %then &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;call symput("record1",records);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thanks in advance,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;V.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 09:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125703#M34552</guid>
      <dc:creator>michtka</dc:creator>
      <dc:date>2013-10-28T09:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: macro (Warning:apparent symbol not resolved)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125704#M34553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the SAS Macro doc and I believe also in the SAS Concepts doc is a detailed description of how the SAS Macro and SAS Language processors interact. It's very important to understand this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for your question:&lt;/P&gt;&lt;P&gt;Lets assume "&amp;amp;n" has a value of "2":&lt;/P&gt;&lt;P&gt;a) resolves on macro level "&amp;amp;n". The SAS language sees then: if 2=1 then call symput("record1",records);&lt;/P&gt;&lt;P&gt;b) tests the macro %if condition on macro level. As the condition is not true the SAS language "sees" nothing. If the condition would be true the SAS language would see: &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;call symput("record1",records);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An alternative way of coding only creating the macro variable for the current value of "&amp;amp;n":&lt;/P&gt;&lt;P&gt;%macro test(n=);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %global record&amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data&amp;nbsp; want&amp;amp;n.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have (obs=&amp;amp;n.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symputx("record&amp;amp;n",records);&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2013 21:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/macro-Warning-apparent-symbol-not-resolved/m-p/125704#M34553</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-10-28T21:38:39Z</dc:date>
    </item>
  </channel>
</rss>

