<?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: Probel of call execute in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Probel-of-call-execute/m-p/92687#M26381</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The argument for CALL EXECUTE is a character expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SAS, when you want to build a character expression from text literals and variable values, you use the concatenation operator ( || ) or concatenation functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your first example fails for the same reason that the below fails:&lt;/P&gt;&lt;PRE&gt;data _null_;
&amp;nbsp; set sashelp.class;
&amp;nbsp; a='%global zzz'name';'; 
&amp;nbsp; put a=;
run;
&lt;/PRE&gt;&lt;P&gt;And below succeeds:&lt;/P&gt;&lt;PRE&gt;data _null_;
&amp;nbsp; set sashelp.class;
&amp;nbsp; a='%global zzz'||name||';';
&amp;nbsp; put a=;
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that help?&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Jun 2012 17:20:22 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2012-06-26T17:20:22Z</dc:date>
    <item>
      <title>Probel of call execute</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Probel-of-call-execute/m-p/92686#M26380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;why It will cause an error in the first data step while the second data step is ok?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;call execute('%global zzz'name';');&lt;BR /&gt;run;&lt;BR /&gt;%put _user_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;call execute('%global zzz'||name||';');&lt;BR /&gt;run;&lt;BR /&gt;%put _user_;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 16:52:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Probel-of-call-execute/m-p/92686#M26380</guid>
      <dc:creator>Mike_Davis</dc:creator>
      <dc:date>2012-06-26T16:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: Probel of call execute</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Probel-of-call-execute/m-p/92687#M26381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The argument for CALL EXECUTE is a character expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In SAS, when you want to build a character expression from text literals and variable values, you use the concatenation operator ( || ) or concatenation functions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So your first example fails for the same reason that the below fails:&lt;/P&gt;&lt;PRE&gt;data _null_;
&amp;nbsp; set sashelp.class;
&amp;nbsp; a='%global zzz'name';'; 
&amp;nbsp; put a=;
run;
&lt;/PRE&gt;&lt;P&gt;And below succeeds:&lt;/P&gt;&lt;PRE&gt;data _null_;
&amp;nbsp; set sashelp.class;
&amp;nbsp; a='%global zzz'||name||';';
&amp;nbsp; put a=;
run;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that help?&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 17:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Probel-of-call-execute/m-p/92687#M26381</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2012-06-26T17:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Probel of call execute</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Probel-of-call-execute/m-p/92688#M26382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Quentin has provided the answer.&amp;nbsp; Your first method does not create a valid character expression, so it fails.&amp;nbsp; The being said, when calling macro statements in a data step with call execute I prefer to wrap them with %nrstr so that they will run sequentially after the datastep completes instead of in place.&amp;nbsp; This is not always important but I find it to be a good practice to follow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; set sashelp.class;&lt;/P&gt;&lt;P&gt; call execute('%nrstr(%global zzz' || name || ';)');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another way to do this would be using call symputx:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; set sashelp.class;&lt;/P&gt;&lt;P&gt; call symputx('zzz'||name,'','g');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 17:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Probel-of-call-execute/m-p/92688#M26382</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2012-06-26T17:34:12Z</dc:date>
    </item>
  </channel>
</rss>

