<?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: sas help to keep checking if dataset exists and run code when it does in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/704406#M215940</link>
    <description>&lt;P&gt;It's a&amp;nbsp;&lt;SPAN&gt;modification date of the dataset file&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;can we do it?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Dec 2020 16:42:44 GMT</pubDate>
    <dc:creator>Ranny</dc:creator>
    <dc:date>2020-12-08T16:42:44Z</dc:date>
    <item>
      <title>sas help to keep checking if dataset exists and run code when it does</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/528783#M144354</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one dataset which gets updated everyday in the server. I have a batch job reading this. The issue is whenever this dataset does not exists, my batch jobs throws error and the code does not run for that day.&lt;/P&gt;&lt;P&gt;Can someone please help me with the code to keep checking if this dataset exists and &lt;STRONG&gt;run the remaining part of the code once it is available in the server in a single day?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for helping me out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 15:22:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/528783#M144354</guid>
      <dc:creator>ankit1may</dc:creator>
      <dc:date>2019-01-21T15:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: sas help to keep checking if dataset exists and run code when it does</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/528784#M144355</link>
      <description>&lt;P&gt;I think this is what you are looking for&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/24/670.html" target="_self"&gt;Determine if a data set exists and conditionally execute additional steps&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 15:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/528784#M144355</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-01-21T15:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: sas help to keep checking if dataset exists and run code when it does</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/528787#M144357</link>
      <description>&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;I have tried this. It only checks once. What I am looking for is , &lt;STRONG&gt;a code to check if datasets exists, if not then wait for 1 hour. After 1 hour, it should check if dataset exists or not again, and if the dataset available, then run the code from that junction.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 15:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/528787#M144357</guid>
      <dc:creator>ankit1may</dc:creator>
      <dc:date>2019-01-21T15:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: sas help to keep checking if dataset exists and run code when it does</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/528861#M144394</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do while (not fileexist("filename"));
  sleep(3600,1);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This step will run until the file is present. You might add code that terminates the program abnormally (abort abend) if too many iterations are done.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jan 2019 18:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/528861#M144394</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-21T18:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: sas help to keep checking if dataset exists and run code when it does</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/704399#M215937</link>
      <description>&lt;P&gt;I have SAS dataset in -&lt;/P&gt;
&lt;P&gt;Libname XYZ "/unix/mypath/project/202012";&lt;/P&gt;
&lt;P&gt;SAS dataset - &lt;STRONG&gt;Project_dataset.sas7bdat&lt;/STRONG&gt;&amp;nbsp; with yesterday's date12/07/2020&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what I want is - If above dataset is available with today's date 12/08/2020 then move to the next step otherwise wait until today's file is available.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can we do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Renny&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 13:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/704399#M215937</guid>
      <dc:creator>Ranny</dc:creator>
      <dc:date>2020-12-08T13:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: sas help to keep checking if dataset exists and run code when it does</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/704405#M215939</link>
      <description>&lt;P&gt;Is that date in a variable in the dataset, or the modification date of the dataset file?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 14:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/704405#M215939</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-08T14:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: sas help to keep checking if dataset exists and run code when it does</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/704406#M215940</link>
      <description>&lt;P&gt;It's a&amp;nbsp;&lt;SPAN&gt;modification date of the dataset file&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;can we do it?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Dec 2020 16:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/704406#M215940</guid>
      <dc:creator>Ranny</dc:creator>
      <dc:date>2020-12-08T16:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: sas help to keep checking if dataset exists and run code when it does</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/704977#M216157</link>
      <description>&lt;P&gt;See this macro code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname XYZ "/unix/mypath/project/202012";

%macro wait_till_ready;
%local today modate x;
%let today = %sysfunc(today());
proc sql noprint;
select datepart(modate) into :modate
from dictionary.tables
where libname = "XYZ" and memname = "PROJECT_DATASET"
;
quit;
%if &amp;amp;sqlobs = 0
%then %do;
  %put "Dataset does not exist!";
  %abort cancel;
%end;
%do %while (&amp;amp;modate ne &amp;amp;today);
  %let x = %sysfunc(sleep(60,1)); /* wait a minute */
  proc sql noprint;
  select datepart(modate) into :modate
  from dictionary.tables
  where libname = "XYZ" and memname = "PROJECT_DATASET"
  ;
  quit;
  %if %sysfunc(today()) gt &amp;amp;today
  %then %do;
    %put "No new data for this day!";
    %abort cancel;
  %end;
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The macro will check first if the dataset exists; if not, a message is issued and an error condition raised, and in a non-interactive session (batch), the session is terminated.&lt;/P&gt;
&lt;P&gt;It retrieves the modification timestamp from DICTIONARY.TABLES, extracts the date, and compares that to the rundate of the job. If the dates don't match, it waits for a minute,&lt;/P&gt;
&lt;P&gt;If the current date exceeds the rundate, a message is issued and the job/submit terminated abnormally.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 08:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-help-to-keep-checking-if-dataset-exists-and-run-code-when-it/m-p/704977#M216157</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-10T08:09:57Z</dc:date>
    </item>
  </channel>
</rss>

