<?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: How to Write a Message to the Log in Do Until Statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600813#M173733</link>
    <description>&lt;P&gt;I would strongly recommend putting some sort of counter inside that loop and if a period of time that you think is excessive passes without finding the file that you end the loop, write an appropriate message somewhere and terminate the job or some sort of "nice" exception handling.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Oct 2019 20:04:16 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-10-31T20:04:16Z</dc:date>
    <item>
      <title>How to Write a Message to the Log in Do Until Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600758#M173709</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I automated a program that processes a file.&amp;nbsp; The file is transferred to a directory (mydir) and is typically available by a certain time (noon lets say).&amp;nbsp; However, activity has grown, thus the file has grown, and has been late to arrive a few times recently.&amp;nbsp; I'm trying to code some handling to check if the file is available, and if it isnt, sleep and write a message to the log until it is available.&amp;nbsp; I'm having trouble getting the message to print to the log.&amp;nbsp; here's my program:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data _null_;
 isthere = 0;
 do until (isthere = 1);
  if fileexist("/mydir/myfile.txt") then isthere = 1;
  else x = sleep(60) and put 'file not available' ; 
end;

libname pdb0 "/mydir";

data temp0;
 set pdb0.myfile;
run;

proc print data = temp0 (obs = 10);
run;&lt;/PRE&gt;&lt;P&gt;Every time the program sleeps, i also want it to print 'file not available' to the log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've searched a bunch but can't seem to find a good solution.&amp;nbsp; Can someone please help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Jon&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 18:00:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600758#M173709</guid>
      <dc:creator>prolifious</dc:creator>
      <dc:date>2019-10-31T18:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to Write a Message to the Log in Do Until Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600785#M173721</link>
      <description>&lt;P&gt;The SAS PUT statement will write to the SAS log by default. There is also a PUTLOG statement that will write explicitly to the SAS log if you have other PUT statements writing elsewhere.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, if you want to trigger SAS processing based on the existence of a file then many schedulers have this capability and then you can avoid coding for this entirely.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 19:20:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600785#M173721</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-10-31T19:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to Write a Message to the Log in Do Until Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600788#M173722</link>
      <description>&lt;P&gt;thank you.&amp;nbsp; where should i code the put then?&amp;nbsp; thats the part im having trouble with.&amp;nbsp; i saw putlog and error, but i couldn't code it correctly. can you please provide an example, please?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 19:23:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600788#M173722</guid>
      <dc:creator>prolifious</dc:creator>
      <dc:date>2019-10-31T19:23:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to Write a Message to the Log in Do Until Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600791#M173723</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  putlog "This is a message in the SAS log";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Oct 2019 19:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600791#M173723</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-10-31T19:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to Write a Message to the Log in Do Until Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600803#M173730</link>
      <description>&lt;P&gt;yes, thank you, but my question is - how do i incorporate that in the else of the do until?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="esle0.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33522i2815F3B5B8D76059/image-size/large?v=v2&amp;amp;px=999" role="button" title="esle0.PNG" alt="esle0.PNG" /&gt;&lt;/span&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 19:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600803#M173730</guid>
      <dc:creator>prolifious</dc:creator>
      <dc:date>2019-10-31T19:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to Write a Message to the Log in Do Until Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600804#M173731</link>
      <description>&lt;P&gt;To create a block of code use DO/END.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else do;
  put 'file not available' ; 
  x = sleep(60);
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Oct 2019 19:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600804#M173731</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-31T19:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to Write a Message to the Log in Do Until Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600813#M173733</link>
      <description>&lt;P&gt;I would strongly recommend putting some sort of counter inside that loop and if a period of time that you think is excessive passes without finding the file that you end the loop, write an appropriate message somewhere and terminate the job or some sort of "nice" exception handling.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 20:04:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600813#M173733</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-31T20:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to Write a Message to the Log in Do Until Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600818#M173736</link>
      <description>&lt;P&gt;here is what ended up working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;else do;
  put 'file not available' ; 
  x = sleep(60,1);
end;&lt;/PRE&gt;&lt;P&gt;without the ,1 in the sleep, i don't beleive the program slept, its jsut kep going through the loop and continually prints 'not available', but now it works as i like.&amp;nbsp; Thanks so much!!&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 20:08:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600818#M173736</guid>
      <dc:creator>prolifious</dc:creator>
      <dc:date>2019-10-31T20:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to Write a Message to the Log in Do Until Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600821#M173738</link>
      <description>&lt;P&gt;i don't really care how many times it goes through, but i do care if it goes past a certain time mark, 1700 for instance.&amp;nbsp; I'll do that.&amp;nbsp; thanks again for all your help out there.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 20:09:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Write-a-Message-to-the-Log-in-Do-Until-Statement/m-p/600821#M173738</guid>
      <dc:creator>prolifious</dc:creator>
      <dc:date>2019-10-31T20:09:45Z</dc:date>
    </item>
  </channel>
</rss>

