<?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 Variable Value containing apostrophes used as on-Condition in proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434829#M281974</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Thank you for your reply. Sadly the ERROR&amp;nbsp;message stays the same.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Feb 2018 13:01:05 GMT</pubDate>
    <dc:creator>Criptic</dc:creator>
    <dc:date>2018-02-07T13:01:05Z</dc:date>
    <item>
      <title>Macro Variable Value containing apostrophes used as on-Condition in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434826#M281972</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as you can maybe guess from the title I'm a little bit lost and don't really know what to search for so here it goes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a STP which takes as one of its arguments a on-condition. That condition can be freely entered by the user.&lt;/P&gt;
&lt;P&gt;And a simple condition, e.g. a.key_value eq b.key_value, works perfectly fine. The problem arises when I want to a join like, e.g. a.key_value eq b.key_value and b.birthday eq '07FEB2018'd, I get the following error-message:&lt;/P&gt;
&lt;P&gt;NOTE: Line generated by the macro variable "JOINCONDITION".&lt;BR /&gt;362 a.key_value eq b.key_value and b.birthday eq '07FEB2018'd&lt;BR /&gt; _&lt;BR /&gt; 22&lt;BR /&gt; _&lt;BR /&gt; 200&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, (, *, +, -, ALL, ANY, BTRIM, CALCULATED, CASE, &lt;BR /&gt; INPUT, PUT, SELECT, SOME, SUBSTRING, TRANSLATE, USER.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The input from the user is stored in a macro variable called JOINCONDITION and proc sql that gets executed is inside of macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I do the exact same thing inside of SAS-Coding and not as part of a STP it works fine and I don't get why.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Coding inside STP:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* For the user input let's say it is again a.key_value eq b.key_value and b.birthday eq '07FEB2018'd */

%macro test();
 /* Somethings that are done beforehand */
proc sql;
create table aaa as
select b.open, a.*
from mydata as a
left join myotherdata as b
on &amp;amp;JOINCONDITION;
run;
%mend test;

%test();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now if I take that coding and paste into a "normal" SAS-coding and set the macro variable JOINCONDITION with %let it works fine:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let JOINCONDITION = a.key_value eq b.key_value and b.birthday eq '07FEB2018'd;

%macro test();
 /* Somethings that are done beforehand */
proc sql;
create table aaa as
select b.open, a.*
from mydata as a
left join myotherdata as b
on &amp;amp;JOINCONDITION;
run;
%mend test;

%test();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Can somebody give me any pointers? I tried &amp;amp;JOINCONDITION. didn't make a difference. Enclosing in " " just created a&amp;nbsp;cartesian product. Any help would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 12:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434826#M281972</guid>
      <dc:creator>Criptic</dc:creator>
      <dc:date>2018-02-07T12:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Value containing apostrophes used as on-Condition in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434827#M281973</link>
      <description>&lt;P&gt;use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%nrbquote(&amp;amp;joincondition)&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 12:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434827#M281973</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-02-07T12:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Value containing apostrophes used as on-Condition in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434829#M281974</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;Thank you for your reply. Sadly the ERROR&amp;nbsp;message stays the same.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 13:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434829#M281974</guid>
      <dc:creator>Criptic</dc:creator>
      <dc:date>2018-02-07T13:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Value containing apostrophes used as on-Condition in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434838#M281975</link>
      <description>&lt;P&gt;Are you working on some jail time and a big fat liability suit? Because that's what's going to happen as soon as a user injects code that deletes all your tables or enters fraudulent data into a critical dataset.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;NEVER, EVER LET USERS ENTER CODE INTO A PROCESS THAT DOES NOT RUN UNDER THEIR OWN USERID!!!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 13:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434838#M281975</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-02-07T13:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Value containing apostrophes used as on-Condition in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434839#M281976</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;Thank you for the concern but this is a non-issue with this as STP-Server-User is not allowed to write, update or delete data in the library it can access.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 13:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434839#M281976</guid>
      <dc:creator>Criptic</dc:creator>
      <dc:date>2018-02-07T13:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Value containing apostrophes used as on-Condition in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434840#M281977</link>
      <description>And the input is validated for semicolons, the words proc, sql, update, drop, delete, alter, etc.</description>
      <pubDate>Wed, 07 Feb 2018 13:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434840#M281977</guid>
      <dc:creator>Criptic</dc:creator>
      <dc:date>2018-02-07T13:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Value containing apostrophes used as on-Condition in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434865#M281978</link>
      <description>&lt;P&gt;As an educated guess, here is what I would try inside the macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;on %unquote(&amp;amp;JOINCONDITION);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems like your process somehow quotes characters in &amp;amp;JOINCONDITION, and SQL is notoriously poor at unquoting them in time for correct parsing.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 14:25:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434865#M281978</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-07T14:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Value containing apostrophes used as on-Condition in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434925#M281979</link>
      <description>&lt;P&gt;Please post logs, especially with errors, into a code box opened using the forum {I} menu icon.&lt;/P&gt;
&lt;P&gt;Note that the main message window reformats text and reduces the information in the error message.&lt;/P&gt;
&lt;P&gt;For instance from your post:&lt;/P&gt;
&lt;P&gt;NOTE: Line generated by the macro variable "JOINCONDITION".&lt;BR /&gt;362 a.key_value eq b.key_value and b.birthday eq '07FEB2018'd&lt;BR /&gt; _&lt;BR /&gt; 22&lt;BR /&gt; _&lt;BR /&gt; 200&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant, a missing value, (, *, +, -, ALL, ANY, BTRIM, CALCULATED, CASE, &lt;BR /&gt; INPUT, PUT, SELECT, SOME, SUBSTRING, TRANSLATE, USER.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The _ character was originally underneath a position in the code where SAS determined the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also post the entire proc or data step generating the error. Sometimes the actual cause is something earlier in the code that wasn't ended correctly but the error isn't triggered until later in the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the message says expecting values like BTRIM, CALCULATED and such I suspect that there is something else going on. I might guess that for some reason the whole macro variable is not being considered as a join condition but just some string not resolving. You might mention HOW the users set that and which interface, Web Report Studio or something else as that is likely doing something to the entered values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc SQL wants a QUIT not a RUN.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Feb 2018 16:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/434925#M281979</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-07T16:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Variable Value containing apostrophes used as on-Condition in proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/435162#M281980</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; Well this was one educated guess! Worked like a charm, thank you very much!</description>
      <pubDate>Thu, 08 Feb 2018 05:40:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Variable-Value-containing-apostrophes-used-as-on-Condition/m-p/435162#M281980</guid>
      <dc:creator>Criptic</dc:creator>
      <dc:date>2018-02-08T05:40:37Z</dc:date>
    </item>
  </channel>
</rss>

