<?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: Some macro functions are not parsed in SAS Studio in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710452#M9653</link>
    <description>&lt;P&gt;You can eliminate the need for the %LEFT() macro call by just not storing the leading spaces into the macro variable to begin with.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select count(*)
  into :num  trimmed
  from t_test 
  where prxmatch('/^test/io',strip(memname))
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 10 Jan 2021 15:36:30 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-01-10T15:36:30Z</dc:date>
    <item>
      <title>Some macro functions are not parsed in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710450#M9651</link>
      <description>&lt;P&gt;Dears:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some macro functions(e.g: %left() function) are not parsed in SAS Studio, but they are effective in SAS EG. And base SAS of both of them are 9.4_M6.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I wonder if I missed any global Settings in SAS Studio env?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find my code in below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc product_status;run;

data test1;
    i=1;
run;

data test2;
    i=2;
run;

data test3;
    i=3;
run;

proc sql ;
    create table t_test as 
    select * from  dictionary.tables where libname='WORK'; 

    select count(*) into:num from t_test where prxmatch('/^test/io',strip(memname));
;quit;

%macro test();
    data all;
        set test1 - test%left(&amp;amp;num.);
    run;
%mend;

%test;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas_eg.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53371i5C69ACCA5C477124/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas_eg.png" alt="sas_eg.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas_studio.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53372i9D789E2512B03449/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas_studio.png" alt="sas_studio.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 15:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710450#M9651</guid>
      <dc:creator>NickZhengCHN</dc:creator>
      <dc:date>2021-01-10T15:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: Some macro functions are not parsed in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710451#M9652</link>
      <description>&lt;P&gt;Interesting problem.&amp;nbsp; Please try a shorter test of the %LEFT() function. Also check the setting for SASAUTOS and set the MAUOTCOMPLOC and MAUTOLOCDISPLAY options.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %sysfunc(getoption(sasautos));
options MAUTOCOMPLOC MAUTOLOCDISPLAY ;
%put "%left(%str(    3))";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please paste the results as text and not as photographs.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 15:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710451#M9652</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-10T15:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Some macro functions are not parsed in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710452#M9653</link>
      <description>&lt;P&gt;You can eliminate the need for the %LEFT() macro call by just not storing the leading spaces into the macro variable to begin with.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select count(*)
  into :num  trimmed
  from t_test 
  where prxmatch('/^test/io',strip(memname))
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Jan 2021 15:36:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710452#M9653</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-10T15:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Some macro functions are not parsed in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710454#M9654</link>
      <description>&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Results as following:&lt;/P&gt;&lt;P&gt;SAS&amp;nbsp; Studio:&lt;/P&gt;&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;72&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;73&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 %put %sysfunc(getoption(sasautos));&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;( "SASEnvironment/SASMacro" '!SASROOT/sasautos' )&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 options MAUTOCOMPLOC MAUTOLOCDISPLAY ;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 %put "%left(%str( 3))";&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MAUTOCOMPLOC: The autocall macro LEFT is compiling using the autocall source file&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;/opt/sasinside/SASHome/SASFoundation/9.4/sasautos/left.sas.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MAUTOLOCDISPLAY(LEFT): This macro was compiled from the autocall file /opt/sasinside/SASHome/SASFoundation/9.4/sasautos/left.sas&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MAUTOCOMPLOC: The autocall macro VERIFY is compiling using the autocall source file&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;/opt/sasinside/SASHome/SASFoundation/9.4/sasautos/verify.sas.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MAUTOLOCDISPLAY(VERIFY): This macro was compiled from the autocall file&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;/opt/sasinside/SASHome/SASFoundation/9.4/sasautos/verify.sas&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;"3"&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;78 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;SAS EG:&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;34 %put %sysfunc(getoption(sasautos));&lt;BR /&gt;SASAUTOS&lt;BR /&gt;35 options MAUTOCOMPLOC MAUTOLOCDISPLAY ;&lt;BR /&gt;36 %put "%left(%str( 3))";&lt;BR /&gt;MAUTOCOMPLOC: The autocall macro LEFT is compiling using the autocall source file&lt;BR /&gt;D:\SAS94\SASHome\SASFoundation\9.4\core\sasmacro\left.sas.&lt;BR /&gt;MAUTOLOCDISPLAY(LEFT): This macro was compiled from the autocall file D:\SAS94\SASHome\SASFoundation\9.4\core\sasmacro\left.sas&lt;BR /&gt;MAUTOCOMPLOC: The autocall macro VERIFY is compiling using the autocall source file&lt;BR /&gt;D:\SAS94\SASHome\SASFoundation\9.4\core\sasmacro\verify.sas.&lt;BR /&gt;MAUTOLOCDISPLAY(VERIFY): This macro was compiled from the autocall file D:\SAS94\SASHome\SASFoundation\9.4\core\sasmacro\verify.sas&lt;BR /&gt;"3"&lt;/DIV&gt;</description>
      <pubDate>Sun, 10 Jan 2021 15:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710454#M9654</guid>
      <dc:creator>NickZhengCHN</dc:creator>
      <dc:date>2021-01-10T15:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Some macro functions are not parsed in SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710455#M9655</link>
      <description>&lt;P&gt;So the %LEFT() function is found and working fine.&lt;/P&gt;
&lt;P&gt;The other issue is that sometimes inside a macro when you use macro code to generate a single token, in this case the token TEST3, the parser can get confused and see it as two tokens.&amp;nbsp; So instead of coding:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set test1 - test%left(&amp;amp;num.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can either build up the token first and then use it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let last =test%left(&amp;amp;num.); 
set test1 - &amp;amp;last;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or add something that lets the parser see it as one token.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set test1 - %unquote(test%left(&amp;amp;num.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also just use a simple %LET to remove the spaces from NUM.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let num=&amp;amp;num;
set test1-test&amp;amp;num;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;But the real solution is to not put the spaces into the macro variable to begin with.&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select count(*) into :num trimmed from t_test where prxmatch('/^test/io',strip(memname));
...
set test1-test&amp;amp;num ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 16:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Some-macro-functions-are-not-parsed-in-SAS-Studio/m-p/710455#M9655</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-10T16:18:17Z</dc:date>
    </item>
  </channel>
</rss>

