<?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: Conditional Start in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339927#M2075</link>
    <description>&lt;P&gt;I guess you're mixing things here. If you work with a process flow, you should use the controls available in process flows. So I'd add a node that checks your dataset and sets a macro variable, which you can then use in conditions in your process flow.&lt;/P&gt;
&lt;P&gt;What &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; and I have given you are options to use with stand-alone SAS code.&lt;/P&gt;
&lt;P&gt;You could try to wrap my solution around the &lt;U&gt;code&lt;/U&gt; of your nodes, but you would lose the process-flow functionality on the way, as you'll end up with a single monolithic piece of code.&lt;/P&gt;
&lt;P&gt;The endsas statement &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; uses immediately terminates the SAS workspace server session, so EG would have to start a new workspace server to continue (which would lose all macro variables etc)&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2017 08:33:38 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-03-10T08:33:38Z</dc:date>
    <item>
      <title>Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339634#M2059</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is run a job based on the date of the month which can vary.&lt;/P&gt;&lt;P&gt;So I was thinking of using conditional start.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I had a table with a list of dates, and that date matched "&amp;amp;sysdate"d - 1 I would want the job to run, but if not stop the job and dont process the job.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone any ideas on how to achieve this, I have looked for examples but am struggling on it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Aidan&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 14:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339634#M2059</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-03-09T14:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339643#M2060</link>
      <description>&lt;P&gt;Do you mean that you have a dataset with dates and jobnames?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 14:28:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339643#M2060</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-09T14:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339648#M2061</link>
      <description>&lt;P&gt;I would have 1 data set with multiple different dates and then if a date within that data set matches today-1, i will run &amp;nbsp;ajob, if not, do nothing&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 14:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339648#M2061</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-03-09T14:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339651#M2062</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/91103"&gt;@Aidan&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I would have 1 data set with multiple different dates and then if a date within that data set matches today-1, i will run &amp;nbsp;ajob, if not, do nothing&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Ok, so I suggest:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro run_job_cond;

%let flag=no;

data _null_;
set have;
if date = today() - 1 then call symput('flag','yes');
run;

%if &amp;amp;flag=yes
%then %do;
/* run the job here */
%end;

%mend;

%run_job_cond&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How you run the job depends on what the "job" is. If it is a SAS code suitable for %include, then you could do that. If it is something that should be run in a clean batch job, use one of the methods to call external commands and use SAS from the commandline.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 14:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339651#M2062</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-09T14:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339652#M2063</link>
      <description>&lt;P&gt;Here's one way to proceed.&amp;nbsp; Take the job you might want to run, and add this to the beginning of it.&amp;nbsp; Assuming you have your list of dates stored in a SAS data set with one date value per observation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;call symputx('date_found', 'endsas;');&lt;/P&gt;
&lt;P&gt;set list_of_dates;&lt;/P&gt;
&lt;P&gt;if date = "&amp;amp;sysdate9"d - 1 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; call symputx('date_found', ' ');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; stop;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;date_found&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When there is no matching date, &amp;amp;DATE_FOUND generates ENDSAS; and the program stops.&amp;nbsp; Just run the program every day.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are other non-SAS approaches that use job schedulers, depending on your operating system.&amp;nbsp; But this would be an easy SAS-based approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 14:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339652#M2063</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-09T14:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339661#M2065</link>
      <description>&lt;P&gt;Thank you both, I have both implemented so hopefully it will work , &amp;nbsp;I will know on the 20th so will accpet solution for whichever works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for the quick reply&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 15:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339661#M2065</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-03-09T15:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339669#M2066</link>
      <description>&lt;P&gt;And as for "running a job every day": if you have the luxury of running SAS on UNIX, a simple crontab entry will do the job.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2017 15:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339669#M2066</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-09T15:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339915#M2074</link>
      <description>&lt;P&gt;If in node 1 the dates match, will it progress onto node 2 as per attachment?&lt;/P&gt;&lt;P&gt;See code in node 1 below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;call symputx('date_found', 'endsas;');&lt;BR /&gt;set &amp;amp;_INPUT1;&lt;BR /&gt;if date = "&amp;amp;sysdate9"d - 1 then do;&lt;BR /&gt;call symputx('date_found', ' ');&lt;BR /&gt;stop;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&amp;amp;date_found&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 08:15:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339915#M2074</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-03-10T08:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339927#M2075</link>
      <description>&lt;P&gt;I guess you're mixing things here. If you work with a process flow, you should use the controls available in process flows. So I'd add a node that checks your dataset and sets a macro variable, which you can then use in conditions in your process flow.&lt;/P&gt;
&lt;P&gt;What &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; and I have given you are options to use with stand-alone SAS code.&lt;/P&gt;
&lt;P&gt;You could try to wrap my solution around the &lt;U&gt;code&lt;/U&gt; of your nodes, but you would lose the process-flow functionality on the way, as you'll end up with a single monolithic piece of code.&lt;/P&gt;
&lt;P&gt;The endsas statement &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; uses immediately terminates the SAS workspace server session, so EG would have to start a new workspace server to continue (which would lose all macro variables etc)&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 08:33:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339927#M2075</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-10T08:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339929#M2076</link>
      <description>&lt;P&gt;startement the next node has code like the below;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create view work.W2LB59M as&lt;BR /&gt;select&lt;BR /&gt;(datepart(BILLING_RUN_DT)) as BILLING_RUN_DT length = 8&lt;BR /&gt;format = date11.&lt;BR /&gt;informat = DATETIME20.&lt;BR /&gt;label = 'BILLING_RUN_DT'&lt;BR /&gt;from &amp;amp;SYSLAST&lt;BR /&gt;where "&amp;amp;Sysdate"d-1&amp;gt;=datepart(BILLING_RUN_DT)&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%let SYSLAST = work.W2LB59M;&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;&lt;P&gt;So I need to put that here as highlitged with "CODE TO PROCESS"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data _null_;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;call symputx('date_found', 'endsas;');&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set &amp;amp;_INPUT1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if date = "&amp;amp;sysdate9"d - 1 then do &amp;nbsp;"CODE TO PROCESS";&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;call symputx('date_found', ' ');&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;stop;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;amp;date_found&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 08:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339929#M2076</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-03-10T08:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339931#M2077</link>
      <description>&lt;P&gt;From the screenshot in your rtf I guess you use EG and process flows?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 08:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339931#M2077</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-10T08:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339932#M2078</link>
      <description>&lt;P&gt;Yeah I use DI more often than not, but have used some user written in the past&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 08:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339932#M2078</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-03-10T08:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339935#M2079</link>
      <description>&lt;P&gt;Since I do not work with DI Studio, you need to take my suggestions from now on with a grain of salt.&lt;/P&gt;
&lt;P&gt;If DI Studio works like EG, you can set conditions for each node in the flow. One of the options (in EG, mind) for such a condition is to query the value of a macro variable.&lt;/P&gt;
&lt;P&gt;If you now enter the data step code that checks the control dataset into a node at the beginning like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let continue=no;
data _null_;
set control;
if date = today() - 2
then do;
  call symput('continue','yes');
  stop;
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then add a condition on the following nodes that queries for &amp;amp;continue=yes.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 08:55:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339935#M2079</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-10T08:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Start</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339942#M2080</link>
      <description>&lt;P&gt;Ok this is where I am at now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table with the last run date on its own, being the 15th of Feb 2017.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is node 1.&lt;/P&gt;&lt;P&gt;Node 2 contains the following, so I want to run a test if the criteria matches which is should.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%let continue=no;&lt;BR /&gt;data temp1;&lt;BR /&gt;set &amp;amp;_INPUT1;&lt;BR /&gt;if BILLING_RUN_DT = '15Feb2017'd&lt;BR /&gt;then do;&lt;BR /&gt;call symput('continue','yes');&lt;BR /&gt;stop;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then node 3 does the processing of the rest of the DI job which has a where clause of&amp;nbsp;&amp;amp;continue=yes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This still doens't seem to be executing from node 3 with any data even though I have data that matches to the 15th of Feb so the condition should be yes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone any ideas at this point?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Aidan&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2017 09:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Conditional-Start/m-p/339942#M2080</guid>
      <dc:creator>Aidan</dc:creator>
      <dc:date>2017-03-10T09:41:21Z</dc:date>
    </item>
  </channel>
</rss>

