<?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 How to conditionally run sas external program in data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735007#M228961</link>
    <description>&lt;P&gt;data test;&lt;BR /&gt;if compress(&amp;amp;MON1.)= compress(&amp;amp;MON2.)&lt;BR /&gt;then I want to run this program "C:\Nitin(C)\SAS &amp;amp; SQL\SAS\SAS_Excel_VBA_Program.sas";&lt;BR /&gt;else Put 'NA';&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*I tried call execute and %include but both options not working*/&lt;/P&gt;&lt;P&gt;Any help will be highly appreciated. thanks!&lt;/P&gt;</description>
    <pubDate>Sun, 18 Apr 2021 02:25:12 GMT</pubDate>
    <dc:creator>nitink26</dc:creator>
    <dc:date>2021-04-18T02:25:12Z</dc:date>
    <item>
      <title>How to conditionally run sas external program in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735007#M228961</link>
      <description>&lt;P&gt;data test;&lt;BR /&gt;if compress(&amp;amp;MON1.)= compress(&amp;amp;MON2.)&lt;BR /&gt;then I want to run this program "C:\Nitin(C)\SAS &amp;amp; SQL\SAS\SAS_Excel_VBA_Program.sas";&lt;BR /&gt;else Put 'NA';&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;/*I tried call execute and %include but both options not working*/&lt;/P&gt;&lt;P&gt;Any help will be highly appreciated. thanks!&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 02:25:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735007#M228961</guid>
      <dc:creator>nitink26</dc:creator>
      <dc:date>2021-04-18T02:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to conditionally run sas external program in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735015#M228962</link>
      <description>&lt;P&gt;Assuming your external program is not only a code snippet for inclusion into a data step but a full program, here some options how to do this. The sample code below is self-contained and fully functional.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create sample demo program demo.sas in SAS Work folder */
%let work_path=%sysfunc(pathname(work));
data _null_;
  file "&amp;amp;work_path/demo.sas";
  put 'proc print data=sashelp.class(obs=1);run;';
run;

%let mon1=Feb2020;
%let mon2=Feb2020;

/* option 1 */
data _null_;
  if compress("&amp;amp;MON1.")= compress("&amp;amp;MON2.") then
    do;
      call execute('%include '||"'&amp;amp;work_path/demo.sas' /source2;");
    end;
  else Put 'NA';
  stop;
RUN;

/* option 2 */
%macro doit(m1,m2); 
  %if &amp;amp;m1=&amp;amp;m2 %then
    %do;
      %include "&amp;amp;work_path/demo.sas" /source2;
    %end;
  %else
    %put NA;
%mend;
%doit(&amp;amp;mon1,&amp;amp;mon2);

/* option 3 (requires a recent SAS release) */
%if &amp;amp;mon1=&amp;amp;mon2 %then
  %do;
    %include "&amp;amp;work_path/demo.sas" /source2;
  %end;
%else
  %do;
    %put NA;
  %end;
&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 04:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735015#M228962</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-18T04:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to conditionally run sas external program in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735054#M228968</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;&lt;P&gt;A quick query - why we are using / source2?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nitin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 05:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735054#M228968</guid>
      <dc:creator>nitink26</dc:creator>
      <dc:date>2021-04-18T05:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to conditionally run sas external program in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735057#M228969</link>
      <description>&lt;P&gt;The source2 option prints the code from an %include statement to the log. That shows you what got executed and also supports debugging if required.&lt;/P&gt;
&lt;P&gt;Btw: You probably should mark my answer as solution and not your "thank you". Except for rare cases it's bad style to mark your own stuff as solution.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 05:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735057#M228969</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-18T05:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to conditionally run sas external program in data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735085#M228991</link>
      <description>&lt;P&gt;Thanks Patrick!&lt;/P&gt;&lt;P&gt;I marked your answer as solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 12:49:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-conditionally-run-sas-external-program-in-data-step/m-p/735085#M228991</guid>
      <dc:creator>nitink26</dc:creator>
      <dc:date>2021-04-18T12:49:45Z</dc:date>
    </item>
  </channel>
</rss>

