<?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: Simple macro resolution fails in Procedures in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69727#M20056</link>
    <description>Hi:&lt;BR /&gt;
  For the definitive answer, you might want to work with Tech Support. It was my understanding that any time you used a quoting function, SAS, behind the scenes used some kind of unprintable (hidden or hex) character to surround the text that was protected with the quoting function.  &lt;BR /&gt;
                       &lt;BR /&gt;
  This SYMBOLGEN message implies the hidden characters:&lt;BR /&gt;
[pre]&lt;BR /&gt;
SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been&lt;BR /&gt;
            unquoted for printing.&lt;BR /&gt;
                                                                                     &lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                                                  &lt;BR /&gt;
  But from this Tech Support note, it looks like the above message gets issued by SYMBOLGEN, but the %STR hidden characters are not really removed:&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/22/353.html" target="_blank"&gt;http://support.sas.com/kb/22/353.html&lt;/A&gt; &lt;BR /&gt;
&lt;BR /&gt;
  I think the safest approach is to use %unquote as the note suggests. I have always found this paper on quoting functions to be good as a general explanation of how quoting functions worked:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi24/Advtutor/p38-24.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi24/Advtutor/p38-24.pdf&lt;/A&gt;&lt;BR /&gt;
                        &lt;BR /&gt;
cynthia</description>
    <pubDate>Mon, 19 Jan 2009 16:40:43 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2009-01-19T16:40:43Z</dc:date>
    <item>
      <title>Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69717#M20046</link>
      <description>The following code seems very simple yet produces an error.&lt;BR /&gt;
&lt;BR /&gt;
-----------------------------------------------------------------&lt;BR /&gt;
%let x=%str(a);&lt;BR /&gt;
%put The value of macro x is --&amp;gt;&amp;amp;x&amp;lt;-- ;&lt;BR /&gt;
&lt;BR /&gt;
* goes ok;&lt;BR /&gt;
  data test&amp;amp;x ; x=1 ; run ;&lt;BR /&gt;
&lt;BR /&gt;
* goes wrong !!???!!??;&lt;BR /&gt;
  proc print out=test&amp;amp;x ; by x ; run ;&lt;BR /&gt;
-----------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
The procedure produces this error (see below) and I can't work out why. Does anyone know?&lt;BR /&gt;
&lt;BR /&gt;
-----------------------------------------------------------------&lt;BR /&gt;
21           proc print out=test&amp;amp;x ; by x ; run ;&lt;BR /&gt;
                        ___&lt;BR /&gt;
                        22&lt;BR /&gt;
                        76&lt;BR /&gt;
&lt;BR /&gt;
ERROR 22-322: Syntax error, expecting one of the following: ;, DATA, DOUBLE, HEADING, LABEL, N, NOOBS, OBS, ROUND, ROWS, SPLIT, &lt;BR /&gt;
              STYLE, UNIFORM, WIDTH.  &lt;BR /&gt;
&lt;BR /&gt;
ERROR 76-322: Syntax error, statement will be ignored.&lt;BR /&gt;
-----------------------------------------------------------------&lt;BR /&gt;
&lt;BR /&gt;
thanks&lt;BR /&gt;
Phil Mason</description>
      <pubDate>Fri, 16 Jan 2009 09:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69717#M20046</guid>
      <dc:creator>PhilMason</dc:creator>
      <dc:date>2009-01-16T09:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69718#M20047</link>
      <description>%str() works fine in procedure calls. I think you have to check your PROC PRINT syntax instead... I guess that your OUT= should be DATA=.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Fri, 16 Jan 2009 09:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69718#M20047</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-01-16T09:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69719#M20048</link>
      <description>Sorry - I had tried a few different PROCs and the last one was a Proc Sort so I hadnt fixed the syntax. However, I still get the error with correct syntax....&lt;BR /&gt;
&lt;BR /&gt;
21         proc print data=test&amp;amp;x ; run ;&lt;BR /&gt;
                                  _&lt;BR /&gt;
                                  200&lt;BR /&gt;
&lt;BR /&gt;
ERROR 200-322: The symbol is not recognized and will be ignored.</description>
      <pubDate>Fri, 16 Jan 2009 09:33:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69719#M20048</guid>
      <dc:creator>PhilMason</dc:creator>
      <dc:date>2009-01-16T09:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69720#M20049</link>
      <description>There is definitely something very strange going on!&lt;BR /&gt;
&lt;BR /&gt;
When I ran this myself, the ‘data test’ step DIDN’T work OK – it created WORK.TEST and WORK.A instead of WORK.TESTA. This suggests that SAS is being passed more than just the ‘a’ when it tries to resolve &amp;amp;x.</description>
      <pubDate>Fri, 16 Jan 2009 10:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69720#M20049</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-16T10:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69721#M20050</link>
      <description>You're right. It's like it has used a format and right justified the argument to %str, so it puts some spaces in front of it. That then explains what you find and the error. I look forward to hearing what the experts at SAS make of this.</description>
      <pubDate>Fri, 16 Jan 2009 11:21:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69721#M20050</guid>
      <dc:creator>PhilMason</dc:creator>
      <dc:date>2009-01-16T11:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69722#M20051</link>
      <description>Sorry, I was too quick there.&lt;BR /&gt;
%str can cause some problems in other situations too, bot can often be resolved by using %unquote. Does this work for your situation? It seems to work with your example.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Fri, 16 Jan 2009 11:54:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69722#M20051</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-01-16T11:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69723#M20052</link>
      <description>Disclaimer: I'm not an expert.&lt;BR /&gt;
&lt;BR /&gt;
This problem is resolved with %UNQUOTE.  Sometimes automatic unquoting does not work and UNQUOTEing is needed.  Notice that the data step produces two data sets WORK.TEST and WORK.A.  No error but not the intended result.  Then in PROC PRINT data = TESTA causes another error.  There are no spaces rather two tokens.</description>
      <pubDate>Fri, 16 Jan 2009 13:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69723#M20052</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-01-16T13:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69724#M20053</link>
      <description>Personally, I'd just not use %str(a) in the first place.&lt;BR /&gt;
%let x = a ;&lt;BR /&gt;
should work just fine.&lt;BR /&gt;
&lt;BR /&gt;
Here's some of my code using something like this.&lt;BR /&gt;
&lt;BR /&gt;
  %let N = %eval(&amp;amp;N + 1);&lt;BR /&gt;
  %let include_file = &amp;amp;BaseRP\&amp;amp;env\main\&amp;amp;home\&amp;amp;job..sas ;&lt;BR /&gt;
&lt;BR /&gt;
  %if "&amp;amp;on_this_system" = "BI" %then %do;&lt;BR /&gt;
&lt;BR /&gt;
    %global BI&amp;amp;N;&lt;BR /&gt;
    %local session_id;&lt;BR /&gt;
    %let session_id = BI&amp;amp;N;&lt;BR /&gt;
    %let all_sessions = %trim(&amp;amp;all_sessions) &amp;amp;session_id ;&lt;BR /&gt;
    %put all_sessions = &amp;amp;all_sessions ;&lt;BR /&gt;
&lt;BR /&gt;
    %if %length(&amp;amp;password) &amp;gt; 0 %then %do;&lt;BR /&gt;
      %RemoteBISignon(&amp;amp;session_id);&lt;BR /&gt;
&lt;BR /&gt;
      %local libdef;&lt;BR /&gt;
      %if %sysfunc(fileexist(&amp;amp;BaseRP\&amp;amp;env\IncludeLib\LibraryDefinitions.sas)) %then&lt;BR /&gt;
        %let libdef = &amp;amp;BaseRP\&amp;amp;env\IncludeLib\LibraryDefinitions.sas ;&lt;BR /&gt;
      %else&lt;BR /&gt;
        %let libdef = &amp;amp;BaseRP\Prod\IncludeLib\LibraryDefinitions.sas ;&lt;BR /&gt;
&lt;BR /&gt;
      %syslput  environment = %bquote(&amp;amp;env)    /remote=&amp;amp;session_id ;&lt;BR /&gt;
      %syslput include_file = &amp;amp;include_file    /remote=&amp;amp;session_id ;&lt;BR /&gt;
      %syslput session_name = session&amp;amp;N        /remote=&amp;amp;session_id ;&lt;BR /&gt;
      %syslput       libdef = %bquote(&amp;amp;libdef) /remote=&amp;amp;session_id ;&lt;BR /&gt;
      rsubmit &amp;amp;session_id wait=no persist=no macvar=session&amp;amp;N SYSRPUTSYNC=yes&lt;BR /&gt;
              log="&amp;amp;base_file..log"&lt;BR /&gt;
              output="&amp;amp;base_file..out"&lt;BR /&gt;
              ;</description>
      <pubDate>Fri, 16 Jan 2009 14:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69724#M20053</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-16T14:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69725#M20054</link>
      <description>this was a simplified example to show the problem but did not explain why we need to use it. We do need to use quoting in this way. We did work out we could use %unquote to fix the problem, but we didnt understand why and so raised it here in hope of getting an explanation from someone in the know. Thanks to all that have responded so far though.</description>
      <pubDate>Mon, 19 Jan 2009 12:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69725#M20054</guid>
      <dc:creator>PhilMason</dc:creator>
      <dc:date>2009-01-19T12:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69726#M20055</link>
      <description>There is definitely something very funky happening:&lt;BR /&gt;
&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
188        %let x=b%str(a);&lt;BR /&gt;
189        %put The value of macro x is --&amp;gt;&amp;amp;x&amp;lt;-- ;&lt;BR /&gt;
The value of macro x is --&amp;gt;ba&amp;lt;--&lt;BR /&gt;
190        &lt;BR /&gt;
191        * goes ok;&lt;BR /&gt;
192        data test&amp;amp;x ; x=1 ; run ;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: Compression was disabled for data set WORK.TESTB because compression overhead would increase the size of the data set.&lt;BR /&gt;
NOTE: Compression was disabled for data set WORK.A because compression overhead would increase the size of the data set.&lt;BR /&gt;
&lt;/PRE&gt;&lt;BR /&gt;
&lt;BR /&gt;
And again&lt;BR /&gt;
&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
188        %let x = b%str(%a) ;&lt;BR /&gt;
WARNING: Apparent invocation of macro A not resolved.&lt;BR /&gt;
189        %put The value of macro x is --&amp;gt;&amp;amp;x&amp;lt;-- ;&lt;BR /&gt;
WARNING: Apparent invocation of macro A not resolved.&lt;BR /&gt;
The value of macro x is --&amp;gt;b%a&amp;lt;--&lt;BR /&gt;
190        &lt;BR /&gt;
191        * goes ok;&lt;BR /&gt;
192        data test&amp;amp;x ; x=1 ; run ;&lt;BR /&gt;
NOTE: Line generated by the macro variable "X".&lt;BR /&gt;
192         testb%a&lt;BR /&gt;
                 _&lt;BR /&gt;
                 _&lt;BR /&gt;
                 _&lt;BR /&gt;
                 22&lt;BR /&gt;
                 22&lt;BR /&gt;
                 22&lt;BR /&gt;
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_.  &lt;BR /&gt;
&lt;/PRE&gt;&lt;BR /&gt;
&lt;BR /&gt;
So, again, I ask, why is %str(a) necessary?&lt;BR /&gt;
I think you may be misusing %str().

Message was edited by: Chuck</description>
      <pubDate>Mon, 19 Jan 2009 14:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69726#M20055</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-19T14:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Simple macro resolution fails in Procedures</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69727#M20056</link>
      <description>Hi:&lt;BR /&gt;
  For the definitive answer, you might want to work with Tech Support. It was my understanding that any time you used a quoting function, SAS, behind the scenes used some kind of unprintable (hidden or hex) character to surround the text that was protected with the quoting function.  &lt;BR /&gt;
                       &lt;BR /&gt;
  This SYMBOLGEN message implies the hidden characters:&lt;BR /&gt;
[pre]&lt;BR /&gt;
SYMBOLGEN:  Some characters in the above value which were subject to macro quoting have been&lt;BR /&gt;
            unquoted for printing.&lt;BR /&gt;
                                                                                     &lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                                                  &lt;BR /&gt;
  But from this Tech Support note, it looks like the above message gets issued by SYMBOLGEN, but the %STR hidden characters are not really removed:&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/22/353.html" target="_blank"&gt;http://support.sas.com/kb/22/353.html&lt;/A&gt; &lt;BR /&gt;
&lt;BR /&gt;
  I think the safest approach is to use %unquote as the note suggests. I have always found this paper on quoting functions to be good as a general explanation of how quoting functions worked:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi24/Advtutor/p38-24.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi24/Advtutor/p38-24.pdf&lt;/A&gt;&lt;BR /&gt;
                        &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 19 Jan 2009 16:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Simple-macro-resolution-fails-in-Procedures/m-p/69727#M20056</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-01-19T16:40:43Z</dc:date>
    </item>
  </channel>
</rss>

