<?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 Query in macro and call execute in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute/m-p/415412#M101884</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CHECKMASTER is a work table which contains attached data. I want to execute the SH jobs one by one in a &amp;nbsp;loop through a table when val = 0 and runstatus = N . Then I want to set the runstatus as 'P' using update_status macro.&lt;/P&gt;&lt;P&gt;But the condition is always false . Also, I am not too sure if my call execute statement to include a sas code is correct .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly advise why the condition is always false and if my call execute statement to include a sas code is correct&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using LINUX Environment . SAS Version is 4.4 .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Below is&amp;nbsp;the code:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;%macro update_status(status=);&lt;BR /&gt;proc sql;&lt;BR /&gt;update exeng.EngineExecution set runstatus="&amp;amp;status"&lt;BR /&gt;where JobName=compress("&amp;amp;&amp;amp;jobs&amp;amp;cnt_h");&lt;BR /&gt;quit;&lt;BR /&gt;%mend update_status;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro jobex;&lt;BR /&gt;%let path=/app/scripts/batch;&lt;BR /&gt;%let extn=sh;&lt;BR /&gt;%global cnt_h;&lt;BR /&gt;%global jobs;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select count(jobname) into :cnt_h separated by ' ' from CHECK_MASTER ;&lt;BR /&gt;select jobname into :jobs1-:jobs%left(&amp;amp;cnt_h) from CHECK_MASTER;&lt;BR /&gt;quit;&lt;BR /&gt;data _null_;&lt;BR /&gt;set work.CHECK_MASTER;&lt;BR /&gt;/*call symputx ("val",val);*/&lt;BR /&gt;/*call symputx ("runstatus",runstatus);*/&lt;BR /&gt;%do i=1 %to &amp;amp;cnt_h;&lt;BR /&gt;%if ((val=0) AND (Runstatus = 'F' or RUNSTATUS='N' )) %then %do;&lt;/P&gt;&lt;P&gt;call execute('%include "&amp;amp;path./&amp;amp;&amp;amp;jobs&amp;amp;i...&amp;amp;extn"');&lt;BR /&gt;/*x "&amp;amp;path/&amp;amp;&amp;amp;jobs&amp;amp;i...&amp;amp;extn";*/&lt;BR /&gt;status="P";&lt;/P&gt;&lt;P&gt;%update_status(status);&lt;BR /&gt;%end;x&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend jobex;&lt;BR /&gt;%jobex;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Log:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MPRINT(JOBEX): data _null_;&lt;BR /&gt;MPRINT(JOBEX): set work.CHECK_MASTER;&lt;BR /&gt;SYMBOLGEN: Macro variable CNT_H resolves to 9&lt;BR /&gt;MLOGIC(JOBEX): %DO loop beginning; index variable I; start value is 1; stop value is 9; by value is 1.&lt;BR /&gt;MLOGIC(JOBEX): %IF condition ((val=0) AND (Runstatus = 'F' or RUNSTATUS='N' )) is FALSE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sandhya S&lt;/P&gt;</description>
    <pubDate>Wed, 22 Nov 2017 08:10:21 GMT</pubDate>
    <dc:creator>Sandy10</dc:creator>
    <dc:date>2017-11-22T08:10:21Z</dc:date>
    <item>
      <title>Query in macro and call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute/m-p/415412#M101884</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CHECKMASTER is a work table which contains attached data. I want to execute the SH jobs one by one in a &amp;nbsp;loop through a table when val = 0 and runstatus = N . Then I want to set the runstatus as 'P' using update_status macro.&lt;/P&gt;&lt;P&gt;But the condition is always false . Also, I am not too sure if my call execute statement to include a sas code is correct .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly advise why the condition is always false and if my call execute statement to include a sas code is correct&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using LINUX Environment . SAS Version is 4.4 .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Below is&amp;nbsp;the code:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;%macro update_status(status=);&lt;BR /&gt;proc sql;&lt;BR /&gt;update exeng.EngineExecution set runstatus="&amp;amp;status"&lt;BR /&gt;where JobName=compress("&amp;amp;&amp;amp;jobs&amp;amp;cnt_h");&lt;BR /&gt;quit;&lt;BR /&gt;%mend update_status;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro jobex;&lt;BR /&gt;%let path=/app/scripts/batch;&lt;BR /&gt;%let extn=sh;&lt;BR /&gt;%global cnt_h;&lt;BR /&gt;%global jobs;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select count(jobname) into :cnt_h separated by ' ' from CHECK_MASTER ;&lt;BR /&gt;select jobname into :jobs1-:jobs%left(&amp;amp;cnt_h) from CHECK_MASTER;&lt;BR /&gt;quit;&lt;BR /&gt;data _null_;&lt;BR /&gt;set work.CHECK_MASTER;&lt;BR /&gt;/*call symputx ("val",val);*/&lt;BR /&gt;/*call symputx ("runstatus",runstatus);*/&lt;BR /&gt;%do i=1 %to &amp;amp;cnt_h;&lt;BR /&gt;%if ((val=0) AND (Runstatus = 'F' or RUNSTATUS='N' )) %then %do;&lt;/P&gt;&lt;P&gt;call execute('%include "&amp;amp;path./&amp;amp;&amp;amp;jobs&amp;amp;i...&amp;amp;extn"');&lt;BR /&gt;/*x "&amp;amp;path/&amp;amp;&amp;amp;jobs&amp;amp;i...&amp;amp;extn";*/&lt;BR /&gt;status="P";&lt;/P&gt;&lt;P&gt;%update_status(status);&lt;BR /&gt;%end;x&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend jobex;&lt;BR /&gt;%jobex;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Log:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MPRINT(JOBEX): data _null_;&lt;BR /&gt;MPRINT(JOBEX): set work.CHECK_MASTER;&lt;BR /&gt;SYMBOLGEN: Macro variable CNT_H resolves to 9&lt;BR /&gt;MLOGIC(JOBEX): %DO loop beginning; index variable I; start value is 1; stop value is 9; by value is 1.&lt;BR /&gt;MLOGIC(JOBEX): %IF condition ((val=0) AND (Runstatus = 'F' or RUNSTATUS='N' )) is FALSE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sandhya S&lt;/P&gt;</description>
      <pubDate>Wed, 22 Nov 2017 08:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute/m-p/415412#M101884</guid>
      <dc:creator>Sandy10</dc:creator>
      <dc:date>2017-11-22T08:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Query in macro and call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute/m-p/415965#M102117</link>
      <description>&lt;P&gt;Hi Sandy10&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;"Kindly advise why the condition is always false ..."&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Your condition is ...&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if ((val=0) AND (Runstatus = 'F' or RUNSTATUS='N' )) %then %do;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;... and this is always false because we have to use macro variables in a %if-%else statement, and cannot use data step variables. Val and Runstatus are both data step variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You could avoid using macros with the call execute; see&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068#toc-hId--480129115" target="_self"&gt;maxim#11&lt;/A&gt;&amp;nbsp;and the sas blog "&lt;A href="https://blogs.sas.com/content/sgf/2017/08/02/call-execute-for-sas-data-driven-programming/" target="_self"&gt;CALL EXECUTE made easy for SAS data-driven programming&lt;/A&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 09:26:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute/m-p/415965#M102117</guid>
      <dc:creator>JohnHoughton</dc:creator>
      <dc:date>2017-11-24T09:26:54Z</dc:date>
    </item>
  </channel>
</rss>

