<?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 macro error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-error/m-p/749619#M235603</link>
    <description>&lt;P&gt;Hello All, I've created the macro below,&amp;nbsp; however when I run the very first SQL statement of my code I keep getting errors??&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Macro&lt;/STRONG&gt; below:&lt;/P&gt;&lt;P&gt;%MACRO NEEDDT(PLM12019,BEGDATE,ENDDATE);&lt;BR /&gt;%LET BEGDATE = MDY(12,31,2019);&lt;BR /&gt;%LET ENDDATE = MDY(01,31,2020);&lt;BR /&gt;%LET CYABSTR =PLM12020; /*use if pulling from a ASQ abstract*/&lt;BR /&gt;%LET PRABSTR =PLM12019;&lt;BR /&gt;%MEND NEEDDT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My first &lt;STRONG&gt;SQL statement&lt;/STRONG&gt; below:&lt;/P&gt;&lt;P&gt;PROC SQL; create table r.originalPLMPOP as select&lt;BR /&gt;PLDOCNUM AS CIDORNUM LABEL='CIDORNUM'&lt;BR /&gt;FROM &amp;amp;PRABSTR&lt;BR /&gt;WHERE EVNTTYPE='07'; /*Prison Population*/&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Errors&lt;/STRONG&gt; below:&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;10 ! create table r.originalPLMPOP as select&lt;BR /&gt;11 PLDOCNUM AS CIDORNUM LABEL='CIDORNUM'&lt;BR /&gt;12 FROM &amp;amp;PRABSTR&lt;BR /&gt;&lt;STRONG&gt;WARNING&lt;/STRONG&gt;: Apparent symbolic reference PRABSTR not resolved.&lt;BR /&gt;12 FROM &amp;amp;PRABSTR&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;&lt;STRONG&gt;ERROR&lt;/STRONG&gt; 22-322: Syntax error, expecting one of the following: a name, a quoted string, (,&lt;BR /&gt;CONNECTION, DICTIONARY.&lt;/P&gt;&lt;P&gt;12 FROM &amp;amp;PRABSTR&lt;BR /&gt;-&lt;BR /&gt;200&lt;BR /&gt;&lt;STRONG&gt;ERROR&lt;/STRONG&gt; 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;13 WHERE EVNTTYPE='07';&lt;BR /&gt;13 ! /*Prison Population*/&lt;BR /&gt;14 QUIT;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Jun 2021 16:14:56 GMT</pubDate>
    <dc:creator>Renee1984</dc:creator>
    <dc:date>2021-06-22T16:14:56Z</dc:date>
    <item>
      <title>macro error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-error/m-p/749619#M235603</link>
      <description>&lt;P&gt;Hello All, I've created the macro below,&amp;nbsp; however when I run the very first SQL statement of my code I keep getting errors??&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Macro&lt;/STRONG&gt; below:&lt;/P&gt;&lt;P&gt;%MACRO NEEDDT(PLM12019,BEGDATE,ENDDATE);&lt;BR /&gt;%LET BEGDATE = MDY(12,31,2019);&lt;BR /&gt;%LET ENDDATE = MDY(01,31,2020);&lt;BR /&gt;%LET CYABSTR =PLM12020; /*use if pulling from a ASQ abstract*/&lt;BR /&gt;%LET PRABSTR =PLM12019;&lt;BR /&gt;%MEND NEEDDT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My first &lt;STRONG&gt;SQL statement&lt;/STRONG&gt; below:&lt;/P&gt;&lt;P&gt;PROC SQL; create table r.originalPLMPOP as select&lt;BR /&gt;PLDOCNUM AS CIDORNUM LABEL='CIDORNUM'&lt;BR /&gt;FROM &amp;amp;PRABSTR&lt;BR /&gt;WHERE EVNTTYPE='07'; /*Prison Population*/&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Errors&lt;/STRONG&gt; below:&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;10 ! create table r.originalPLMPOP as select&lt;BR /&gt;11 PLDOCNUM AS CIDORNUM LABEL='CIDORNUM'&lt;BR /&gt;12 FROM &amp;amp;PRABSTR&lt;BR /&gt;&lt;STRONG&gt;WARNING&lt;/STRONG&gt;: Apparent symbolic reference PRABSTR not resolved.&lt;BR /&gt;12 FROM &amp;amp;PRABSTR&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;&lt;STRONG&gt;ERROR&lt;/STRONG&gt; 22-322: Syntax error, expecting one of the following: a name, a quoted string, (,&lt;BR /&gt;CONNECTION, DICTIONARY.&lt;/P&gt;&lt;P&gt;12 FROM &amp;amp;PRABSTR&lt;BR /&gt;-&lt;BR /&gt;200&lt;BR /&gt;&lt;STRONG&gt;ERROR&lt;/STRONG&gt; 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;13 WHERE EVNTTYPE='07';&lt;BR /&gt;13 ! /*Prison Population*/&lt;BR /&gt;14 QUIT;&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 16:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-error/m-p/749619#M235603</guid>
      <dc:creator>Renee1984</dc:creator>
      <dc:date>2021-06-22T16:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: macro error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-error/m-p/749620#M235604</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;amp;PRABSTR has not been defined in the current scope where SQL is running. You probably need to learn about &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n10i4tmalsyhgxn1hj4ud13ff074.htm" target="_self"&gt;macro scopes&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;When you define &amp;amp;PRABSTR inside the macro named %NEEDDT, then &amp;amp;PRABSTR does not exist outside of that macro. There are two way to get around this. The easiest is to not define &amp;amp;PRABSTR inside %NEEDDT, define &amp;amp;PRAVSTR outside of a macro, and then it is consider Global and can be accessed anywhere in your program.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;By the way, your macro %NEEDDT as shown, doesn't seem to be needed, as all of the&amp;nbsp; commands in that macro can be (and should be) issued outside of a macro.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 16:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-error/m-p/749620#M235604</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-22T16:29:43Z</dc:date>
    </item>
    <item>
      <title>Re: macro error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-error/m-p/749670#M235640</link>
      <description>&lt;P&gt;Thank you very much, this worked perfectly...making it global!! Problem Solved&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 18:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-error/m-p/749670#M235640</guid>
      <dc:creator>Renee1984</dc:creator>
      <dc:date>2021-06-22T18:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: macro error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-error/m-p/749703#M235657</link>
      <description>&lt;P&gt;You don't show any code that is using that macro.&amp;nbsp; If you want to use the value it is assigning to&amp;nbsp;&lt;SPAN&gt;PRABSTR after it ends make sure that&amp;nbsp;PRABSTR exists before you call the macro.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let PRABSTR=;
%let BEGDATE=;
%let ENDDATE=;
%NEEDDT;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 20:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-error/m-p/749703#M235657</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-22T20:11:55Z</dc:date>
    </item>
  </channel>
</rss>

