<?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: Query in macro and call execute based on sample data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416317#M102202</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anybody else has a solution ? I am actually stuck up in else clause.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and Regards&lt;/P&gt;&lt;P&gt;Sandhya S&lt;/P&gt;</description>
    <pubDate>Mon, 27 Nov 2017 10:57:31 GMT</pubDate>
    <dc:creator>Sandy10</dc:creator>
    <dc:date>2017-11-27T10:57:31Z</dc:date>
    <item>
      <title>Query in macro and call execute based on sample data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/415917#M102093</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When val=0, I am executing a set of jobs, when val = 1, then I have to check if its dependents run status if "P", if so then I have to execute the job. Dependents are in different table. Attached the data for your reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the Job &lt;SPAN&gt;J_RM_T_BSRM_MASTER002&amp;nbsp;&lt;/SPAN&gt; in CHECK Table, val =1 , so I have to check MASTER table for the dependents(&lt;SPAN&gt;J_RM_T_BSRM_MASTER001&lt;/SPAN&gt;&amp;nbsp;and &lt;SPAN&gt;J_RM_T_BSRM_MASTER003&lt;/SPAN&gt;), then again compare with CHECK table to runstatus which is "P" , if "P", the &amp;nbsp;I have to trigger the job &lt;SPAN&gt;J_RM_T_BSRM_MASTER002&lt;/SPAN&gt; (This part I can use X command)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note&amp;nbsp;&lt;SPAN&gt;J_RM_T_BSRM_MASTER001 and&amp;nbsp;J_RM_T_BSRM_MASTER003 will be triggered as ist dependents are with val=0, so it has to be triggered automatically.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is just a small set of jobs, so I am triggering based on a table &amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the data for reference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.CHECK;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input JOBNAME:$100. RUNSTATUS:$1. val:32.;&lt;BR /&gt;datalines4;&lt;BR /&gt;J_RM_T_BSRM_MASTER001,,1&lt;BR /&gt;J_RM_T_BSRM_CHILD001,,0&lt;BR /&gt;J_RM_T_BSRM_CHILD002,,0&lt;BR /&gt;J_RM_T_BSRM_CHILD003,,0&lt;BR /&gt;J_RM_T_BSRM_MASTER002,,1&lt;BR /&gt;J_RM_T_BSRM_MASTER003,,1&lt;BR /&gt;J_RM_T_BSRM_CHILD004,,0&lt;BR /&gt;J_RM_T_BSRM_CHILD005,,0&lt;BR /&gt;J_RM_T_BSRM_CHILD006,,0&lt;BR /&gt;;;;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data WORK.MASTER;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;input job_name:$30. Dependentjobname:$30.;&lt;BR /&gt;datalines4;&lt;BR /&gt;J_RM_T_BSRM_MASTER001,J_RM_T_BSRM_CHILD001&lt;BR /&gt;J_RM_T_BSRM_MASTER001,J_RM_T_BSRM_CHILD002&lt;BR /&gt;J_RM_T_BSRM_MASTER001,J_RM_T_BSRM_CHILD003&lt;BR /&gt;J_RM_T_BSRM_MASTER002,J_RM_T_BSRM_MASTER001&lt;BR /&gt;J_RM_T_BSRM_MASTER002,J_RM_T_BSRM_MASTER003&lt;BR /&gt;J_RM_T_BSRM_MASTER003,J_RM_T_BSRM_CHILD004&lt;BR /&gt;J_RM_T_BSRM_MASTER003,J_RM_T_BSRM_CHILD005&lt;BR /&gt;J_RM_T_BSRM_MASTER003,J_RM_T_BSRM_CHILD006&lt;BR /&gt;;;;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and Regards&lt;/P&gt;&lt;P&gt;Sandhya S&lt;/P&gt;</description>
      <pubDate>Fri, 24 Nov 2017 03:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/415917#M102093</guid>
      <dc:creator>Sandy10</dc:creator>
      <dc:date>2017-11-24T03:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Query in macro and call execute based on sample data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416227#M102181</link>
      <description>&lt;P&gt;Something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data PGM_LIST;
  input PGM_PARENT $3. PGM_CHILD $6. HAS_RUN ;
  PGM_CHILD    = tranwrd(PGM_CHILD,',',' ');
  DO_BEFORE_RUN= PGM_CHILD;
cards;
P4 P1,P2 0
P1 P2    0
P2       0
run;     

data _null_;                                   
  do while(1);                     
    rc= dosubl('proc sql; select PGM_PARENT into :runthis from PGM_LIST where DO_BEFORE_RUN=" " and HAS_RUN=0; quit;'); 
    if symget('sqlobs') ne '0' then RUNTHIS=symget('runthis');            
    else leave ;
    * call execute(RUNTHIS);  putlog 'Running ' RUNTHIS;      
    rc= dosubl('proc sql; update PGM_LIST set DO_BEFORE_RUN=tranwrd(DO_BEFORE_RUN, '||quote(strip(RUNTHIS))||', " " ); quit;'); 
    rc= dosubl('proc sql; update PGM_LIST set HAS_RUN=1 where PGM_PARENT='||quote(trim(RUNTHIS))||'; quit;');
  end; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Running P2&lt;BR /&gt;Running P1&lt;/P&gt;
&lt;P&gt;Running P4&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>Mon, 27 Nov 2017 00:53:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416227#M102181</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-11-27T00:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Query in macro and call execute based on sample data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416316#M102201</link>
      <description>&lt;P&gt;Hi Chris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If there are more child jobs then i think it will not work as the length will be big to accomodate. Currently its a small table, going forward child job count will increase. Thanks .&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 10:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416316#M102201</guid>
      <dc:creator>Sandy10</dc:creator>
      <dc:date>2017-11-27T10:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Query in macro and call execute based on sample data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416317#M102202</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anybody else has a solution ? I am actually stuck up in else clause.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks and Regards&lt;/P&gt;&lt;P&gt;Sandhya S&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 10:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416317#M102202</guid>
      <dc:creator>Sandy10</dc:creator>
      <dc:date>2017-11-27T10:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Query in macro and call execute based on sample data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416497#M102255</link>
      <description>&lt;P&gt;Is a 32k string not long enough ?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 20:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416497#M102255</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-11-27T20:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Query in macro and call execute based on sample data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416504#M102258</link>
      <description>&lt;P&gt;Here is a slight variation, a bit more code, but cleaner data storage&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data PGM_STATUS;
  input PGM_PARENT $ HAS_RUN ;
cards;
P4 0
P1 0
P2 0
run;  
data PGM_DEPEND;
  input PGM_PARENT $3. PGM_CHILD $3.  ;
  DO_BEFORE_RUN= PGM_CHILD;
cards;
P4 P1 
P4 P2 
P1 P2 
P2    
run;     

data _null_;                                   
  do while(1);                     
    rc= dosubl('proc sql; select s.PGM_PARENT into :runthis 
                          from PGM_STATUS s left join PGM_DEPEND d 
                          on s.PGM_PARENT=d.PGM_PARENT and DO_BEFORE_RUN ne " " 
                          where HAS_RUN=0 
                          having d.PGM_PARENT is null; quit;'); 
    if symget('sqlobs') ne '0' then RUNTHIS=symget('runthis');            
    else leave ;
    * call execute(RUNTHIS);  putlog 'Running ' RUNTHIS;      
    rc= dosubl('proc sql; update PGM_DEPEND set DO_BEFORE_RUN=" " where PGM_CHILD ='||quote(trim(RUNTHIS))||'; quit;'); 
    rc= dosubl('proc sql; update PGM_STATUS set HAS_RUN      = 1  where PGM_PARENT='||quote(trim(RUNTHIS))||'; quit;');
  end; 
run;
                    &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Nov 2017 21:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-in-macro-and-call-execute-based-on-sample-data/m-p/416504#M102258</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-11-27T21:03:36Z</dc:date>
    </item>
  </channel>
</rss>

