<?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: call execute in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/338998#M77298</link>
    <description>&lt;P&gt;Yes you can use Call Execute. The documentation has a really good example of data driven execution, see Example 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n1q1527d51eivsn1ob5hnz0yd1hx.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n1q1527d51eivsn1ob5hnz0yd1hx.htm&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Mar 2017 21:05:00 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-03-07T21:05:00Z</dc:date>
    <item>
      <title>call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/338992#M77296</link>
      <description>&lt;P&gt;heres is the code:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; makehospnum;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; rownum hospnum;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;1 5&lt;/P&gt;&lt;P&gt;2 8&lt;/P&gt;&lt;P&gt;3 9&lt;/P&gt;&lt;P&gt;4 10&lt;/P&gt;&lt;P&gt;5 11&lt;/P&gt;&lt;P&gt;6 12&lt;/P&gt;&lt;P&gt;7 13&lt;/P&gt;&lt;P&gt;8 19&lt;/P&gt;&lt;P&gt;9 21&lt;/P&gt;&lt;P&gt;10 25&lt;/P&gt;&lt;P&gt;11 30&lt;/P&gt;&lt;P&gt;12 41&lt;/P&gt;&lt;P&gt;13 42&lt;/P&gt;&lt;P&gt;14 43&lt;/P&gt;&lt;P&gt;15 44&lt;/P&gt;&lt;P&gt;16 98&lt;/P&gt;&lt;P&gt;17 99&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; makehospnum;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"nobs"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, compress(_n_));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;&lt;I&gt;doit&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%global&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; runnum;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; K = &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%to&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;nobs;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;set makehospnum;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;if rownum = &amp;amp;k then call symput(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"runnum"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;, compress(hospnum));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;%&lt;STRONG&gt;&lt;I&gt;do_zscore&lt;/I&gt;&lt;/STRONG&gt;(infile = ed_data_temp, hospvar= &amp;amp;runnum , numlags= &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; hospnum = &amp;amp;runnum;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; doit;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;doit&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering instead of looping over the hospital numbers could i use a call execute command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;thank you,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LK&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 20:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/338992#M77296</guid>
      <dc:creator>lu2kaseff</dc:creator>
      <dc:date>2017-03-07T20:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/338998#M77298</link>
      <description>&lt;P&gt;Yes you can use Call Execute. The documentation has a really good example of data driven execution, see Example 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n1q1527d51eivsn1ob5hnz0yd1hx.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n1q1527d51eivsn1ob5hnz0yd1hx.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 21:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/338998#M77298</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-07T21:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/339001#M77300</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;PRE&gt;data _null_;
   set makehospnum;

   call execute('%do_zscore(infile = ed_data_temp, hospvar='||hospnum||', numlags= 30);');

run;
&lt;/PRE&gt;
&lt;P&gt;Here you want the macro call inside single quotes to keep it from attempting to resolve within the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 21:08:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/339001#M77300</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-07T21:08:56Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/339016#M77307</link>
      <description>&lt;P&gt;Unfortunately, SAS makes you jump through additional hoops to suppress macro activity within CALL EXECUTE.&amp;nbsp; You may need to switch to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;call execute(&lt;FONT color="#000000"&gt;'&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;%nrstr(&lt;/FONT&gt;&lt;/STRONG&gt;%do_zscore(infile = ed_data_temp, hospvar='||hospnum||', numlags= 30);&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;)&lt;/FONT&gt;&lt;/STRONG&gt;');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, you could simplify your original loop slightly by switching to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set makehospnum (firstobs=&amp;amp;k obs=&amp;amp;k);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; call symputx("runnum", hospnum);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That way, the %PUT statement runs in its proper place, something that is more difficult to accomplish with CALL EXECUTE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 21:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/339016#M77307</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-07T21:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/339026#M77312</link>
      <description>&lt;P&gt;Yes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set makehospnum;
  call execute(catx(' ','%nrstr(%do_zscore)(infile = ed_data_temp,'
    ,'hospvar=',hospnum,',numlags=30);'
  ));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just write the code to a file and include it. &amp;nbsp;if you dataset variable names match your macro parameter names you can use the VAR= syntax in the PUT statement to write both the parameter name and the value. &amp;nbsp;To demonstrate let me rename your dataset variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set makehospnum(keep=hospnum rename=(hospnum=hospvar));
  put '%do_zscore(infile=ed_data_temp,numlags=30,' hospvar= ');' ;
run;
%include code /source2;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Mar 2017 21:51:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/339026#M77312</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-07T21:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/339070#M77333</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Does not exactly answer your question but might help

Means for variables defined in a meta dataset

inspired by
https://goo.gl/YZ0QDK
https://communities.sas.com/t5/Base-SAS-Programming/call-execute/m-p/338992


HAVE the following meta datasets
=================================

 up to 40 obs from meta total obs=2

 bs     VAR

 1     HEIGHT
 2     WEIGHT

and sashelp.class


p to 40 obs from sashelp.class total obs=19

bs    NAME       SEX    AGE    HEIGHT    WEIGHT

 1    Alfred      M      14     69.0      112.5
 2    Alice       F      13     56.5       84.0
 3    Barbara     F      13     65.3       98.0
 4    Carol       F      14     62.8      102.5
 5    Henry       M      14     63.5      102.5
 6    James       M      12     57.3       83.0
 7    Jane        F      12     59.8       84.5
 8    Janet       F      15     62.5      112.5

WANT (proc means for variables in meta data)
==============================================

                    Analysis Variable : HEIGHT

 N            Mean         Std Dev         Minimum         Maximum
------------------------------------------------------------------
19      62.3368421       5.1270752      51.3000000      72.0000000
------------------------------------------------------------------



                   Analysis Variable : WEIGHT

N            Mean         Std Dev         Minimum         Maximum
-----------------------------------------------------------------
9     100.0263158      22.7739335      50.5000000     150.0000000
-----------------------------------------------------------------

WORKING CODE
============

     call symputx('hvar',hospvar);
     rc=dosubl('
       %do_zscore(infile=sashelp.class,numlags=30,hospvar=&amp;amp;hvar);
     ');

FULL SOLUTION
=============

%symdel hvar; * just in case it exists;
proc datasets lib=work;
delete meta;
run;quit;

data meta;
   do var='HEIGHT','WEIGHT';
     output;
   end;
run;quit;

* SAS solution;

%macro do_zscore(infile = ed_data_temp,hospvar=,numlags=30);
   proc means data=&amp;amp;infile.;
   var &amp;amp;hospvar.;
   run;quit;
%mend do_zscore;

data _null_;
   set meta(keep=var rename=var=hospvar);
   call symputx('hvar',hospvar);
     rc=dosubl('
       %do_zscore(infile=sashelp.class,numlags=30,hospvar=&amp;amp;hvar);
     ');
run;quit;

or


data _null_;
   set meta(keep=var rename=var=hospvar);
   call symputx('hvar',hospvar);
     rc=dosubl('
        proc means data=sashelp.class;
        var &amp;amp;hvar.;
        run;quit;
     ');
run;quit;

You could easily add infile macro var to meta data

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Mar 2017 01:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-execute/m-p/339070#M77333</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-08T01:23:03Z</dc:date>
    </item>
  </channel>
</rss>

