<?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: Error Resolving Macro Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Error-Resolving-Macro-Variable/m-p/829703#M327815</link>
    <description>&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Aug 2022 17:01:55 GMT</pubDate>
    <dc:creator>Jeff_DOC</dc:creator>
    <dc:date>2022-08-22T17:01:55Z</dc:date>
    <item>
      <title>Error Resolving Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Resolving-Macro-Variable/m-p/829698#M327811</link>
      <description>&lt;P&gt;Good morning. I'm hoping someone could help me with an error I'm receiving.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've simplified my steps as much as I can to attempt to pin down where my error is coming from but so far I've been unsuccessful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In running the attached code I get the following error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, &lt;BR /&gt;a numeric constant, a datetime constant, a missing value, BTRIM, INPUT, PUT, SUBSTRING, &lt;BR /&gt;USER.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I'm attempting to do is to initialize a variable and then use that variable in a SQL step. The first error I received was the SQL step looking for the "location_str" variable as a column in the SAS_COMM_TEST_DATA file. That was really strange since I am looking at the values within the location variable not the actual variable names. These steps seem pretty straight forward but I can't seem to determine where I've gone wrong with either error. I know there must be a better way to do this but this is what I have in an attempt to just get it to work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd sure appreciate any help or advice on how to best/better proceed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	if week_day = 2 then do;
		location_str = 'LOCA 1';
		title_location = 'LOCA 1';
	end;

	call symput("location_str",location_str);
	call symput("title_location",title_location);
run;

proc sql;
	create table test_01 as
	select a.key, a.location
	from SAS_COMM_TEST_DATA as a
	where a.location contains (&amp;amp;location_str.)
	order by a.key;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="128" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;&lt;FONT size="3"&gt;&lt;A name="RANGE!A1:B21" target="_blank"&gt;&lt;/A&gt;key&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;&lt;FONT size="3"&gt;location&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;1&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 1&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;2&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 2&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;3&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 3&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;4&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 4&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;5&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 5&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;6&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 6&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;7&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 7&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;8&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 8&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;9&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 9&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;10&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 10&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;11&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 11&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;12&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 12&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;13&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 13&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;14&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 14&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;15&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 15&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;16&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 16&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;17&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 17&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;18&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 18&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;19&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 19&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" style="height: 15.0pt;"&gt;&lt;FONT size="3"&gt;20&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT size="3"&gt;LOCA 20&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 16:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Resolving-Macro-Variable/m-p/829698#M327811</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2022-08-22T16:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error Resolving Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Resolving-Macro-Variable/m-p/829700#M327812</link>
      <description>If you change CALL SYMPUT to CALL SYMPUTX() does that work?</description>
      <pubDate>Mon, 22 Aug 2022 16:54:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Resolving-Macro-Variable/m-p/829700#M327812</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-08-22T16:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Error Resolving Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Resolving-Macro-Variable/m-p/829701#M327813</link>
      <description>&lt;P&gt;I am assuming that variable location is a character string, so you must compare it to a character string. Thus you need double-quotes around the macro variable to indicate that you have a character string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where a.location contains ("&amp;amp;location_str")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From now on, please when there is an error in the log, show us the ENTIRE log for that PROC or DATA step. Do not show us errors disconnected from the code as it appears in the log.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 16:56:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Resolving-Macro-Variable/m-p/829701#M327813</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-08-22T16:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: Error Resolving Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Error-Resolving-Macro-Variable/m-p/829703#M327815</link>
      <description>&lt;P&gt;Thank you very much.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 17:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Error-Resolving-Macro-Variable/m-p/829703#M327815</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2022-08-22T17:01:55Z</dc:date>
    </item>
  </channel>
</rss>

