<?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 Error handling for missing file using FILENAME statement. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61254#M17379</link>
    <description>I relatively new to SAS but a strong mainframe COBOL/Assembler coder. Is there error handling logic in SAS that will intercept and reset the return code back to a job stream? I have a simple SAS job that takes current days date - 1 and adds that date variable to the end of a file name to map and store in a pdb. When the file hasn't been created, I don't want my job to fail. Simple go on to the next step of the job stream and continue. Any help/suggestions would be appreciated. Thanks!&lt;BR /&gt;
&lt;BR /&gt;
Here is my simple SAS job:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;DATA _NULL_;                                          &lt;BR /&gt;
 DTRUN=TODAY()-1;                                     &lt;BR /&gt;
 DTRUN1=(PUT(DTRUN,YYMMDD6.));                        &lt;BR /&gt;
 CALL SYMPUT('DYYMMDD',DTRUN1);                       &lt;BR /&gt;
 STOP;                                                &lt;BR /&gt;
 RUN;                                                 &lt;BR /&gt;
                                                      &lt;BR /&gt;
DATA LNX_USERS;                                       &lt;BR /&gt;
                                                      &lt;BR /&gt;
 FILENAME LXGSTMEM "SYS90H.LNXMEM.D&amp;amp;DYYMMDD" DISP=SHR;&lt;BR /&gt;
                                                      &lt;BR /&gt;
 INFILE LXGSTMEM DELIMITER=',' DSD FIRSTOBS=2;        &lt;BR /&gt;
                                                      &lt;BR /&gt;
    INPUT GUEST    :$8.                               &lt;BR /&gt;
          DATETIME :$15.                              &lt;BR /&gt;
          TOTMEM   :8.                                &lt;BR /&gt;
          KBMEMFR  :8.                                &lt;BR /&gt;
          KBMEMUS  :8.                                &lt;BR /&gt;
          PCTMEMUS :5.2                               &lt;BR /&gt;
          KBBUFFRS :8.                                &lt;BR /&gt;
          KBCACHED :8.                                &lt;BR /&gt;
          KBSWPFR  :8.                                &lt;BR /&gt;
          KBSWPUS  :8.                                &lt;BR /&gt;
          PCTSWPUS :5.2                               &lt;BR /&gt;
          KBSWPCAD :8.;                               &lt;BR /&gt;
                                                      &lt;BR /&gt;
      LNXDATE = TODAY()-1;&lt;BR /&gt;
&lt;BR /&gt;
%PUT SYSERR=&amp;amp;SYSERR; &lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Here is the output when the file is missing:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;7        !                                                                     &lt;BR /&gt;
8                                                                              &lt;BR /&gt;
9          DATA LNX_USERS;                                                     &lt;BR /&gt;
10                                                                             &lt;BR /&gt;
11          FILENAME LXGSTMEM "SYS90H.LNXMEM.D&amp;amp;DYYMMDD" DISP=SHR;              &lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110109&lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110109&lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110109&lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                        &lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                        &lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                        &lt;BR /&gt;
11       !                                                                     &lt;BR /&gt;
12                                                                             &lt;BR /&gt;
13          INFILE LXGSTMEM DELIMITER=',' DSD FIRSTOBS=2;                      &lt;BR /&gt;
14                                                                             &lt;BR /&gt;
15             INPUT GUEST    :$8.                                             &lt;BR /&gt;
16                   DATETIME :$15.                                            &lt;BR /&gt;
17                   TOTMEM   :8.                                              &lt;BR /&gt;
18                   KBMEMFR  :8.                                              &lt;BR /&gt;
19                   KBMEMUS  :8.                                              &lt;BR /&gt;
20                   PCTMEMUS :5.2                                             &lt;BR /&gt;
21                   KBBUFFRS :8.                                              &lt;BR /&gt;
22                   KBCACHED :8.                                              &lt;BR /&gt;
23                   KBSWPFR  :8.                                              &lt;BR /&gt;
24                   KBSWPUS  :8.                                              &lt;BR /&gt;
25                   PCTSWPUS :5.2                                             &lt;BR /&gt;
26                   KBSWPCAD :8.;                                             &lt;BR /&gt;
27                                                                             &lt;BR /&gt;
28               LNXDATE = TODAY()-1;                                          &lt;BR /&gt;
29                                                                              &lt;BR /&gt;
30         %PUT SYSERR=&amp;amp;SYSERR;                                                 &lt;BR /&gt;
SYSERR=0                                                                        &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                 &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                 &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                 &lt;BR /&gt;
NOTE: THE SAS SYSTEM STOPPED PROCESSING THIS STEP BECAUSE OF ERRORS.            &lt;BR /&gt;
NOTE: SAS SET OPTION OBS=0 AND WILL CONTINUE TO CHECK STATEMENTS. THIS MAY CAUSE&lt;BR /&gt;
WARNING: THE DATA SET WORK.LNX_USERS MAY BE INCOMPLETE.  WHEN THIS STEP WAS STOP&lt;BR /&gt;
NOTE: THE DATA STATEMENT USED THE FOLLOWING RESOURCES:                          &lt;BR /&gt;
      CPU     TIME -         00:00:00.02                                        &lt;BR /&gt;
      ELAPSED TIME -         00:00:00.21                                        &lt;BR /&gt;
      EXCP COUNT   - 91                                                         &lt;BR /&gt;
      TASK  MEMORY - 3806K (120K DATA, 3686K PROGRAM)                           &lt;BR /&gt;
      TOTAL MEMORY - 17249K (6048K DATA, 11201K PROGRAM)                        &lt;BR /&gt;
NOTE: THE ADDRESS SPACE HAS USED A MAXIMUM OF 664K BELOW THE LINE AND 17772K ABO&lt;BR /&gt;
                                                                                &lt;BR /&gt;
                                                                                &lt;BR /&gt;
ERROR: SAS ENDED DUE TO ERRORS.                                                 &lt;BR /&gt;
ERROR: SAS ENDED DUE TO ERRORS.                                                 &lt;BR /&gt;
ERROR: SAS ENDED DUE TO ERRORS.                                                 &lt;BR /&gt;
3                                                          THE SAS SYSTEM       &lt;BR /&gt;
                                                                                &lt;BR /&gt;
       YOU SPECIFIED: OPTIONS ERRORABEND;.                                      &lt;BR /&gt;
       YOU SPECIFIED: OPTIONS ERRORABEND;.                                      &lt;BR /&gt;
       YOU SPECIFIED: OPTIONS ERRORABEND;.                                      &lt;BR /&gt;
ERROR: ERRORS PRINTED ON PAGES 2,3.                                             &lt;BR /&gt;
ERROR: ERRORS PRINTED ON PAGES 2,3.                                             &lt;BR /&gt;
ERROR: ERRORS PRINTED ON PAGES 2,3.&lt;/B&gt;</description>
    <pubDate>Mon, 10 Jan 2011 16:20:36 GMT</pubDate>
    <dc:creator>G_I_Jeff</dc:creator>
    <dc:date>2011-01-10T16:20:36Z</dc:date>
    <item>
      <title>Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61254#M17379</link>
      <description>I relatively new to SAS but a strong mainframe COBOL/Assembler coder. Is there error handling logic in SAS that will intercept and reset the return code back to a job stream? I have a simple SAS job that takes current days date - 1 and adds that date variable to the end of a file name to map and store in a pdb. When the file hasn't been created, I don't want my job to fail. Simple go on to the next step of the job stream and continue. Any help/suggestions would be appreciated. Thanks!&lt;BR /&gt;
&lt;BR /&gt;
Here is my simple SAS job:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;DATA _NULL_;                                          &lt;BR /&gt;
 DTRUN=TODAY()-1;                                     &lt;BR /&gt;
 DTRUN1=(PUT(DTRUN,YYMMDD6.));                        &lt;BR /&gt;
 CALL SYMPUT('DYYMMDD',DTRUN1);                       &lt;BR /&gt;
 STOP;                                                &lt;BR /&gt;
 RUN;                                                 &lt;BR /&gt;
                                                      &lt;BR /&gt;
DATA LNX_USERS;                                       &lt;BR /&gt;
                                                      &lt;BR /&gt;
 FILENAME LXGSTMEM "SYS90H.LNXMEM.D&amp;amp;DYYMMDD" DISP=SHR;&lt;BR /&gt;
                                                      &lt;BR /&gt;
 INFILE LXGSTMEM DELIMITER=',' DSD FIRSTOBS=2;        &lt;BR /&gt;
                                                      &lt;BR /&gt;
    INPUT GUEST    :$8.                               &lt;BR /&gt;
          DATETIME :$15.                              &lt;BR /&gt;
          TOTMEM   :8.                                &lt;BR /&gt;
          KBMEMFR  :8.                                &lt;BR /&gt;
          KBMEMUS  :8.                                &lt;BR /&gt;
          PCTMEMUS :5.2                               &lt;BR /&gt;
          KBBUFFRS :8.                                &lt;BR /&gt;
          KBCACHED :8.                                &lt;BR /&gt;
          KBSWPFR  :8.                                &lt;BR /&gt;
          KBSWPUS  :8.                                &lt;BR /&gt;
          PCTSWPUS :5.2                               &lt;BR /&gt;
          KBSWPCAD :8.;                               &lt;BR /&gt;
                                                      &lt;BR /&gt;
      LNXDATE = TODAY()-1;&lt;BR /&gt;
&lt;BR /&gt;
%PUT SYSERR=&amp;amp;SYSERR; &lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Here is the output when the file is missing:&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;7        !                                                                     &lt;BR /&gt;
8                                                                              &lt;BR /&gt;
9          DATA LNX_USERS;                                                     &lt;BR /&gt;
10                                                                             &lt;BR /&gt;
11          FILENAME LXGSTMEM "SYS90H.LNXMEM.D&amp;amp;DYYMMDD" DISP=SHR;              &lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110109&lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110109&lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110109&lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                        &lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                        &lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                        &lt;BR /&gt;
11       !                                                                     &lt;BR /&gt;
12                                                                             &lt;BR /&gt;
13          INFILE LXGSTMEM DELIMITER=',' DSD FIRSTOBS=2;                      &lt;BR /&gt;
14                                                                             &lt;BR /&gt;
15             INPUT GUEST    :$8.                                             &lt;BR /&gt;
16                   DATETIME :$15.                                            &lt;BR /&gt;
17                   TOTMEM   :8.                                              &lt;BR /&gt;
18                   KBMEMFR  :8.                                              &lt;BR /&gt;
19                   KBMEMUS  :8.                                              &lt;BR /&gt;
20                   PCTMEMUS :5.2                                             &lt;BR /&gt;
21                   KBBUFFRS :8.                                              &lt;BR /&gt;
22                   KBCACHED :8.                                              &lt;BR /&gt;
23                   KBSWPFR  :8.                                              &lt;BR /&gt;
24                   KBSWPUS  :8.                                              &lt;BR /&gt;
25                   PCTSWPUS :5.2                                             &lt;BR /&gt;
26                   KBSWPCAD :8.;                                             &lt;BR /&gt;
27                                                                             &lt;BR /&gt;
28               LNXDATE = TODAY()-1;                                          &lt;BR /&gt;
29                                                                              &lt;BR /&gt;
30         %PUT SYSERR=&amp;amp;SYSERR;                                                 &lt;BR /&gt;
SYSERR=0                                                                        &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                 &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                 &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                 &lt;BR /&gt;
NOTE: THE SAS SYSTEM STOPPED PROCESSING THIS STEP BECAUSE OF ERRORS.            &lt;BR /&gt;
NOTE: SAS SET OPTION OBS=0 AND WILL CONTINUE TO CHECK STATEMENTS. THIS MAY CAUSE&lt;BR /&gt;
WARNING: THE DATA SET WORK.LNX_USERS MAY BE INCOMPLETE.  WHEN THIS STEP WAS STOP&lt;BR /&gt;
NOTE: THE DATA STATEMENT USED THE FOLLOWING RESOURCES:                          &lt;BR /&gt;
      CPU     TIME -         00:00:00.02                                        &lt;BR /&gt;
      ELAPSED TIME -         00:00:00.21                                        &lt;BR /&gt;
      EXCP COUNT   - 91                                                         &lt;BR /&gt;
      TASK  MEMORY - 3806K (120K DATA, 3686K PROGRAM)                           &lt;BR /&gt;
      TOTAL MEMORY - 17249K (6048K DATA, 11201K PROGRAM)                        &lt;BR /&gt;
NOTE: THE ADDRESS SPACE HAS USED A MAXIMUM OF 664K BELOW THE LINE AND 17772K ABO&lt;BR /&gt;
                                                                                &lt;BR /&gt;
                                                                                &lt;BR /&gt;
ERROR: SAS ENDED DUE TO ERRORS.                                                 &lt;BR /&gt;
ERROR: SAS ENDED DUE TO ERRORS.                                                 &lt;BR /&gt;
ERROR: SAS ENDED DUE TO ERRORS.                                                 &lt;BR /&gt;
3                                                          THE SAS SYSTEM       &lt;BR /&gt;
                                                                                &lt;BR /&gt;
       YOU SPECIFIED: OPTIONS ERRORABEND;.                                      &lt;BR /&gt;
       YOU SPECIFIED: OPTIONS ERRORABEND;.                                      &lt;BR /&gt;
       YOU SPECIFIED: OPTIONS ERRORABEND;.                                      &lt;BR /&gt;
ERROR: ERRORS PRINTED ON PAGES 2,3.                                             &lt;BR /&gt;
ERROR: ERRORS PRINTED ON PAGES 2,3.                                             &lt;BR /&gt;
ERROR: ERRORS PRINTED ON PAGES 2,3.&lt;/B&gt;</description>
      <pubDate>Mon, 10 Jan 2011 16:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61254#M17379</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2011-01-10T16:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61255#M17380</link>
      <description>How about this?&lt;BR /&gt;
%macro readfile(dsn);&lt;BR /&gt;
%if %sysfunc(FILEEXIST("&amp;amp;dsn"))=1 %then %do;&lt;BR /&gt;
filename ....;&lt;BR /&gt;
data xyz;&lt;BR /&gt;
  infile ....;&lt;BR /&gt;
run;&lt;BR /&gt;
filename .... clear;&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend  readfile;&lt;BR /&gt;
%readfile(abc.edf.D&amp;amp;yymmdd);</description>
      <pubDate>Mon, 10 Jan 2011 17:06:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61255#M17380</guid>
      <dc:creator>advoss</dc:creator>
      <dc:date>2011-01-10T17:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61256#M17381</link>
      <description>you can test the return code from a filename statement in macro variable &amp;amp;SYSFILRC&lt;BR /&gt;
you also have a function allowing your data step to detect whether the file exists &lt;BR /&gt;
if not fileexist( "SYS90H.LNXMEM.D&amp;amp;DYYMMDD" ) then &lt;BR /&gt;
  abort return 23 ;&lt;BR /&gt;
 &lt;BR /&gt;
and the SAS step return code should be 23&lt;BR /&gt;
which your system job scheduler or JCL can test for.</description>
      <pubDate>Mon, 10 Jan 2011 17:11:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61256#M17381</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-01-10T17:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61257#M17382</link>
      <description>Thanks advoss but I don't know anything about SAS macros. I can maybe half read/understand the code you posted. I'll try and give it a shot though.</description>
      <pubDate>Mon, 10 Jan 2011 18:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61257#M17382</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2011-01-10T18:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61258#M17383</link>
      <description>&amp;gt; you can test the return code from a filename&lt;BR /&gt;
&amp;gt; statement in macro variable &amp;amp;SYSFILRC&lt;BR /&gt;
&amp;gt; you also have a function allowing your data step to&lt;BR /&gt;
&amp;gt; detect whether the file exists &lt;BR /&gt;
&amp;gt; if not fileexist( "SYS90H.LNXMEM.D&amp;amp;DYYMMDD" ) then &lt;BR /&gt;
&amp;gt;   abort return 23 ;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; and the SAS step return code should be 23&lt;BR /&gt;
&amp;gt; which your system job scheduler or JCL can test for.&lt;BR /&gt;
&lt;BR /&gt;
Thanks Peter, this looks like what I am somewhat used to. Buuuttttt,......&lt;BR /&gt;
I put your if statement in my DATA LNX_USERS step and the job still fails with a U0999 return code.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;7        !                                                                     &lt;BR /&gt;
8                                                                              &lt;BR /&gt;
9          DATA LNX_USERS;                                                     &lt;BR /&gt;
10                                                                             &lt;BR /&gt;
11          FILENAME LXGSTMEM "SYS90H.LNXMEM.D&amp;amp;DYYMMDD" DISP=SHR;              &lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110111&lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110111&lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110111&lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                        &lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                        &lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                        &lt;BR /&gt;
11       !                                                                     &lt;BR /&gt;
12                                                                             &lt;BR /&gt;
13          INFILE LXGSTMEM DELIMITER=',' DSD FIRSTOBS=2;                      &lt;BR /&gt;
14                                                                             &lt;BR /&gt;
15             INPUT GUEST    :$8.                                             &lt;BR /&gt;
16                   DATETIME :$15.                                            &lt;BR /&gt;
17                   TOTMEM   :8.                                              &lt;BR /&gt;
18                   KBMEMFR  :8.                                              &lt;BR /&gt;
19                   KBMEMUS  :8.                                              &lt;BR /&gt;
20                   PCTMEMUS :5.2                                             &lt;BR /&gt;
21                   KBBUFFRS :8.                                              &lt;BR /&gt;
22                   KBCACHED :8.                                              &lt;BR /&gt;
23                   KBSWPFR  :8.                                              &lt;BR /&gt;
24                   KBSWPUS  :8.                                              &lt;BR /&gt;
25                   PCTSWPUS :5.2                                             &lt;BR /&gt;
26                   KBSWPCAD :8.;                                             &lt;BR /&gt;
27                                                                             &lt;BR /&gt;
28               LNXDATE = TODAY()-1;                                          &lt;BR /&gt;
29                                                                             &lt;BR /&gt;
30         IF NOT FILEEXIST("SYS90H.LNXMEM.D&amp;amp;DYYMMDD") THEN ABORT RETURN 4;    &lt;BR /&gt;
31                                                                             &lt;BR /&gt;
                                                                               &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
Do you think that the job fails at the FILENAME statement and ignores the rest? Thanks for your input!</description>
      <pubDate>Mon, 10 Jan 2011 19:21:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61258#M17383</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2011-01-10T19:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61259#M17384</link>
      <description>I think you need to add OPTION NOERRORABEND to your SAS code.&lt;BR /&gt;
&lt;BR /&gt;
When ERRORABEND is on and the SAS program encounters an error it turns on the ABEND flag for that step.</description>
      <pubDate>Mon, 10 Jan 2011 19:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61259#M17384</guid>
      <dc:creator>OS2Rules</dc:creator>
      <dc:date>2011-01-10T19:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61260#M17385</link>
      <description>I think you can get the desired result with FILEEXISTS and FILEVAR option on infile statement.  Using filevar will prevent SAS from trying to open the file that does not exist, as it does with "regular infile".&lt;BR /&gt;
&lt;BR /&gt;
This is untested code so proceed accordingly.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
DATA LNX_USERS; &lt;BR /&gt;
   length filename $256;&lt;BR /&gt;
   filename = "SYS90H.LNXMEM.D&amp;amp;DYYMMDD";&lt;BR /&gt;
   if FILEEXIST(filename) then do;&lt;BR /&gt;
      INFILE DUMMY DELIMITER=',' DSD FIRSTOBS=2 end=eof filevar=filename; &lt;BR /&gt;
      do while(not eof);&lt;BR /&gt;
         INPUT GUEST :$8.&lt;BR /&gt;
               ...&lt;BR /&gt;
               KBSWPCAD :8.; &lt;BR /&gt;
         LNXDATE = TODAY()-1; &lt;BR /&gt;
         output;&lt;BR /&gt;
         end;&lt;BR /&gt;
      end;&lt;BR /&gt;
   stop;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 10 Jan 2011 20:05:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61260#M17385</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-01-10T20:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61261#M17386</link>
      <description>Hi OS2 Rules,&lt;BR /&gt;
&lt;BR /&gt;
I did that in my last run, after looking up the OPTIONS statement. It stopped abending but the job finished with a return code = 8. It looks as if it is ignoring my FILEEXIST condition statement completely. I even moved it up immediately after the FILENAME statement and no change.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;1                                                                               &lt;BR /&gt;
2                                                          THE SAS SYSTEM       &lt;BR /&gt;
                                                                                &lt;BR /&gt;
2          OPTIONS NOERRABEND;                                                  &lt;BR /&gt;
3                                                                               &lt;BR /&gt;
4          DATA _NULL_;                                                         &lt;BR /&gt;
5           DTRUN=TODAY()-1;                                                    &lt;BR /&gt;
6           DTRUN1=(PUT(DTRUN,YYMMDD6.));                                       &lt;BR /&gt;
7           CALL SYMPUT('DYYMMDD',DTRUN1);                                      &lt;BR /&gt;
8           STOP;                                                               &lt;BR /&gt;
9           RUN;                                                                &lt;BR /&gt;
                                                                                &lt;BR /&gt;
NOTE: THE DATA STATEMENT USED THE FOLLOWING RESOURCES:                          &lt;BR /&gt;
      CPU     TIME -         00:00:00.00                                        &lt;BR /&gt;
      ELAPSED TIME -         00:00:00.04                                        &lt;BR /&gt;
      EXCP COUNT   - 23                                                         &lt;BR /&gt;
      TASK  MEMORY - 3222K (123K DATA, 3099K PROGRAM)                           &lt;BR /&gt;
      TOTAL MEMORY - 16989K (6048K DATA, 10941K PROGRAM)                        &lt;BR /&gt;
NOTE: THE ADDRESS SPACE HAS USED A MAXIMUM OF 664K BELOW THE LINE AND 17508K ABO&lt;BR /&gt;
                                                                                &lt;BR /&gt;
                                                                                &lt;BR /&gt;
9        !                                                                      &lt;BR /&gt;
10                                                                              &lt;BR /&gt;
11         DATA LNX_USERS;                                                      &lt;BR /&gt;
12                                                                              &lt;BR /&gt;
13          FILENAME LXGSTMEM "SYS90H.LNXMEM.D&amp;amp;DYYMMDD" DISP=SHR;               &lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110109 &lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110109 &lt;BR /&gt;
ERROR: SVC99 ERROR RC=4, REASON=1708 : IKJ56228I DATA SET SYS90H.LNXMEM.D110109 &lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                         &lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                         &lt;BR /&gt;
ERROR: ERROR IN THE FILENAME STATEMENT.                                         &lt;BR /&gt;
13       !                                                                      &lt;BR /&gt;
14                                                                              &lt;BR /&gt;
15          IF NOT FILEEXIST("SYS90H.LNXMEM.D&amp;amp;DYYMMDD") THEN ABORT RETURN 4;    &lt;BR /&gt;
16                                                                              &lt;BR /&gt;
17          INFILE LXGSTMEM DELIMITER=',' DSD FIRSTOBS=2;                       &lt;BR /&gt;
18                                                                              &lt;BR /&gt;
19             INPUT GUEST    :$8.                                              &lt;BR /&gt;
20                   DATETIME :$15.                                             &lt;BR /&gt;
21                   TOTMEM   :8.                                               &lt;BR /&gt;
22                   KBMEMFR  :8.                                               &lt;BR /&gt;
23                   KBMEMUS  :8.                                               &lt;BR /&gt;
24                   PCTMEMUS :5.2                                              &lt;BR /&gt;
25                   KBBUFFRS :8.                                               &lt;BR /&gt;
26                   KBCACHED :8.                                               &lt;BR /&gt;
27                   KBSWPFR  :8.                                               &lt;BR /&gt;
28                   KBSWPUS  :8.                                               &lt;BR /&gt;
29                   PCTSWPUS :5.2                                              &lt;BR /&gt;
30                   KBSWPCAD :8.;                                              &lt;BR /&gt;
31                                                                              &lt;BR /&gt;
32               LNXDATE = TODAY()-1;                                           &lt;BR /&gt;
33                                                                              &lt;BR /&gt;
                                                                                &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                 &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                 &lt;BR /&gt;
ERROR: NO LOGICAL ASSIGN FOR FILENAME LXGSTMEM.                                 &lt;BR /&gt;
NOTE: THE SAS SYSTEM STOPPED PROCESSING THIS STEP BECAUSE OF ERRORS.            &lt;BR /&gt;
NOTE: SAS SET OPTION OBS=0 AND WILL CONTINUE TO CHECK STATEMENTS. THIS MAY CAUSE&lt;BR /&gt;
WARNING: THE DATA SET WORK.LNX_USERS MAY BE INCOMPLETE.  WHEN THIS STEP WAS STOP&lt;BR /&gt;
NOTE: THE DATA STATEMENT USED THE FOLLOWING RESOURCES:                          &lt;BR /&gt;
      CPU     TIME -         00:00:00.02                                        &lt;BR /&gt;
      ELAPSED TIME -         00:00:00.21                                        &lt;BR /&gt;
      EXCP COUNT   - 98                                                         &lt;BR /&gt;
      TASK  MEMORY - 3806K (120K DATA, 3686K PROGRAM)                           &lt;BR /&gt;
      TOTAL MEMORY - 17249K (6048K DATA, 11201K PROGRAM)                        &lt;BR /&gt;
NOTE: THE ADDRESS SPACE HAS USED A MAXIMUM OF 664K BELOW THE LINE AND 17772K ABO&lt;BR /&gt;
3                                                          THE SAS SYSTEM       &lt;BR /&gt;
                                                                                &lt;BR /&gt;
                                                                                &lt;BR /&gt;
                                                                                &lt;BR /&gt;
ERROR: ERRORS PRINTED ON PAGE 2.                                                &lt;BR /&gt;
ERROR: ERRORS PRINTED ON PAGE 2.                                                &lt;BR /&gt;
ERROR: ERRORS PRINTED ON PAGE 2.                                                &lt;BR /&gt;
                                                                                &lt;BR /&gt;
NOTE: THE SAS SESSION USED 2.32 CPU SECONDS AND 17249K.                         &lt;BR /&gt;
                                                                                &lt;BR /&gt;
NOTE: THE ADDRESS SPACE HAS USED A MAXIMUM OF 664K BELOW THE LINE AND 17772K ABO&lt;BR /&gt;
                                                                                &lt;BR /&gt;
NOTE: SAS INSTITUTE INC., SAS CAMPUS DRIVE, CARY, NC USA 27513-2414&lt;/B&gt;</description>
      <pubDate>Mon, 10 Jan 2011 20:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61261#M17386</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2011-01-10T20:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61262#M17387</link>
      <description>data _null_;&lt;BR /&gt;
&lt;BR /&gt;
That works, to a point. If the file doesn't exist, I need to set the return code to a specific value so I can flag it in the job stream. So would I just create an ELSE statement off the IF FILEEXIST, setting the return code to, say 4, by:&lt;BR /&gt;
&lt;BR /&gt;
IF FILEEXISTS(FILENAME) THEN DO;&lt;BR /&gt;
  ...&lt;BR /&gt;
  ...&lt;BR /&gt;
  ...&lt;BR /&gt;
ELSE ABORT RETURN 4;&lt;BR /&gt;
&lt;BR /&gt;
I'll give it a try while your mulling that over! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 10 Jan 2011 20:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61262#M17387</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2011-01-10T20:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61263#M17388</link>
      <description>May be you need macro variable.&lt;BR /&gt;
Long time no see. @data _null_;&lt;BR /&gt;
&lt;BR /&gt;
BTW,You also can search dictionary table " dictionary.tables " to find whether the dataset you needed is exist.then set a Return Code to it customsizely .&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let file_name=sashelp.class;&lt;BR /&gt;
%let file_exist= %sysfunc(exist(&amp;amp;file_name));&lt;BR /&gt;
%put NOTE: 1 is exist , 0 is non-exist: &amp;amp;file_exist;&lt;BR /&gt;
&lt;BR /&gt;
DATA LNX_USERS; &lt;BR /&gt;
   length filename $256;&lt;BR /&gt;
   filename = "&amp;amp;file_name";&lt;BR /&gt;
   if &amp;amp;file_exist then do;&lt;BR /&gt;
      INFILE DUMMY DELIMITER=',' DSD FIRSTOBS=2 end=eof filevar=filename; &lt;BR /&gt;
      do while(not eof);&lt;BR /&gt;
         INPUT GUEST :$8.&lt;BR /&gt;
               ...&lt;BR /&gt;
               KBSWPCAD :8.; &lt;BR /&gt;
         LNXDATE = TODAY()-1; &lt;BR /&gt;
         output;&lt;BR /&gt;
         end;&lt;BR /&gt;
      end;&lt;BR /&gt;
   stop;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp

Message was edited by: Ksharp</description>
      <pubDate>Tue, 11 Jan 2011 03:21:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61263#M17388</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-01-11T03:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61264#M17389</link>
      <description>Need to perform that FILEexist() check and "abort return 4;" before the infile statement compiles and tries to use the data. That can be deferred with the FILEVAR= option on the infile statement but I think it looks simpler if you place the test in the preceding data step where the date suffix is derived.  &lt;BR /&gt;
peterC</description>
      <pubDate>Tue, 11 Jan 2011 07:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61264#M17389</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-01-11T07:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61265#M17390</link>
      <description>Here is one more way you can try&lt;BR /&gt;
&lt;BR /&gt;
SAS cannot determine during the compilation phase that the data file is not available and it will start the execution. We have control! But now we have to create the link with the data file and test whether it is available in the  DATA step ourselves:&lt;BR /&gt;
&lt;BR /&gt;
FILENAME myinput dummy;&lt;BR /&gt;
&lt;BR /&gt;
%LET Filename =d:\inputfiels\myfile.csv;&lt;BR /&gt;
&lt;BR /&gt;
DATA mydata;&lt;BR /&gt;
RETAIN InputFile "&amp;amp;Filename" ErrorCount 0;&lt;BR /&gt;
IF FILEEXIST("&amp;amp;filename") THEN DO&lt;BR /&gt;
INFILE myinput DELIMITER='09'x MISSOVER DSD LRECL=32767 FIRSTOBS=2&lt;BR /&gt;
FILEVAR=InputFile END=eof;&lt;BR /&gt;
Informat .....&lt;BR /&gt;
Input........&lt;BR /&gt;
IF _ERROR_ THEN ErrorCount +1;&lt;BR /&gt;
IF eof THEN CALL SYMPUTX('Status',ErrorCount);&lt;BR /&gt;
END;&lt;BR /&gt;
ELSE DO;&lt;BR /&gt;
PUT "Input file &amp;amp;filename not available";&lt;BR /&gt;
CALL SYMPUTX('Status',-1);&lt;BR /&gt;
STOP;&lt;BR /&gt;
END;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
The FILEVAR option in the INFILE statement allows you to specify the input file at execution time. So what we do is&lt;BR /&gt;
we store the path and file name in the macro variable Filename and assign that value to the variable InputFile. Next&lt;BR /&gt;
we test whether the file is there with the FILEEXIST function and if it exists we use it in the FILEVAR option of the&lt;BR /&gt;
INFILE statement to read the input. If it does not exist, we issue the error message and stop the DATA step&lt;BR /&gt;
gracefully with the STOP statement. No error messages or warnings in the SAS log.</description>
      <pubDate>Tue, 11 Jan 2011 10:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61265#M17390</guid>
      <dc:creator>dhana</dc:creator>
      <dc:date>2011-01-11T10:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61266#M17391</link>
      <description>Here's some of what I've been doing recently. (Big caveat: all of this is from memory since&lt;BR /&gt;
I haven't coded a single line of SAS for more than three months now).&lt;BR /&gt;
&lt;BR /&gt;
The basic idea is to modularize the code which allows to execute parts of it conditionally.&lt;BR /&gt;
&lt;BR /&gt;
So my code usually looks somewhat like&lt;BR /&gt;
[pre]&lt;BR /&gt;
  %include ddname(member1) ;&lt;BR /&gt;
  %include ddname(member2) ;&lt;BR /&gt;
  %include ddname(member3) ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
By putting an asterisk in front of "%include" parts of the code can be deactivated.&lt;BR /&gt;
SAS's idiosyncratic way of interpreting, compiling, executing the program code allows&lt;BR /&gt;
to make this process dynamic.&lt;BR /&gt;
&lt;BR /&gt;
So back to some sample code&lt;BR /&gt;
[pre]&lt;BR /&gt;
... some code that executes unconditionally ...&lt;BR /&gt;
&lt;BR /&gt;
/* macro variables can be created/modified in open code       */&lt;BR /&gt;
/* where 'open code' means that the statements are not        */&lt;BR /&gt;
/* embedded in a data/proc step nor in a macro routine either */&lt;BR /&gt;
&lt;BR /&gt;
%let dsname    = THE.MVS.DATASET.NAME ;&lt;BR /&gt;
%let _catlgd   = %sysfunc(dsncatlgd("&amp;amp;dsname")) ;  /* returns 0 or 1 */&lt;BR /&gt;
%let _filexist = %sysfunc(fileexist("&amp;amp;dsname")) ;  /* returns 0 or 1 */&lt;BR /&gt;
&lt;BR /&gt;
/* function DSNCATLGD has the advantage of not allocating the dataset */&lt;BR /&gt;
/* dynamically. Instead it does a catalog lookup.                     */&lt;BR /&gt;
/* Choose whichever function is more appropriate for your case.       */&lt;BR /&gt;
&lt;BR /&gt;
/* now we use these values to extract either a blank or an asterisk */&lt;BR /&gt;
/* from %str(* )                                                    */&lt;BR /&gt;
&lt;BR /&gt;
%let _asterisk1 = %sysfunc(substr(%str(* ),%eval(&amp;amp;_catlgd  +1),1)) ;&lt;BR /&gt;
%let _asterisk2 = %sysfunc(substr(%str(* ),%eval(&amp;amp;_filexist+1),1)) ;&lt;BR /&gt;
&lt;BR /&gt;
/* as a result &amp;amp;_asterisk determines whether the next statement            */&lt;BR /&gt;
/* will be interpreted as a comment statement or an executable statement   */&lt;BR /&gt;
/* i.e. whether member "member" will be included or not                    */&lt;BR /&gt;
&lt;BR /&gt;
&amp;amp;_asterisk1%include ddname(member) ; /* member being included conditionally */&lt;BR /&gt;
&lt;BR /&gt;
... some more code that executes unconditionally ...&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Hope this helps. Or at least gives you some ideas.&lt;BR /&gt;
And of course, I'm not using long variable names like &amp;amp;_asterisk in my programs.</description>
      <pubDate>Wed, 12 Jan 2011 05:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61266#M17391</guid>
      <dc:creator>Robert_Bardos</dc:creator>
      <dc:date>2011-01-12T05:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61267#M17392</link>
      <description>Thanks everyone for their input! I truly appreciate your help and will always come back here when I'm frantically banging my head against my desk. Some of you put more advanced stuff here than I'm willing to try AT THIS POINT. I will definitely play around with it in the future and again, thanks for posting it. But the winner in this post is.........&lt;BR /&gt;
&lt;BR /&gt;
DATA _NULL_;  !!!!!&lt;BR /&gt;
&lt;BR /&gt;
I achieved my desired results with their code and a very slight modification:&lt;BR /&gt;
&lt;BR /&gt;
OPTIONS NOERRABEND;                                                   &lt;BR /&gt;
                                                                      &lt;BR /&gt;
DATA _NULL_;                                                          &lt;BR /&gt;
 DTRUN=TODAY()+1;                                                     &lt;BR /&gt;
 DTRUN1=(PUT(DTRUN,YYMMDD6.));                                        &lt;BR /&gt;
 CALL SYMPUT('DYYMMDD',DTRUN1);                                       &lt;BR /&gt;
 STOP;                                                                &lt;BR /&gt;
 RUN;                                                                 &lt;BR /&gt;
                                                                      &lt;BR /&gt;
DATA LNX_USERS;                                                       &lt;BR /&gt;
                                                                      &lt;BR /&gt;
 LENGTH FILENAME $256;                                                &lt;BR /&gt;
 FILENAME = "SYS90H.LNXMEM.D&amp;amp;DYYMMDD";                                &lt;BR /&gt;
                                                                      &lt;BR /&gt;
  IF FILEEXIST(FILENAME) THEN DO;                                     &lt;BR /&gt;
                                                                      &lt;BR /&gt;
   INFILE DUMMY DELIMITER=',' DSD FIRSTOBS=2 END=EOF FILEVAR=FILENAME;&lt;BR /&gt;
    DO WHILE(NOT EOF);                                                &lt;BR /&gt;
    INPUT GUEST    :$8.                                               &lt;BR /&gt;
          DATETIME :$15.                                              &lt;BR /&gt;
          TOTMEM   :8.                                                &lt;BR /&gt;
          KBMEMFR  :8.                                                &lt;BR /&gt;
          KBMEMUS  :8.                                                &lt;BR /&gt;
          PCTMEMUS :5.2                                               &lt;BR /&gt;
          KBBUFFRS :8.                                                &lt;BR /&gt;
          KBCACHED :8.                                                &lt;BR /&gt;
          KBSWPFR  :8.                                                &lt;BR /&gt;
          KBSWPUS  :8.                                                &lt;BR /&gt;
          PCTSWPUS :5.2                                               &lt;BR /&gt;
          KBSWPCAD :8.;                                               &lt;BR /&gt;
                                                                      &lt;BR /&gt;
      LNXDATE = TODAY()-1;                                            &lt;BR /&gt;
    OUTPUT;                                                           &lt;BR /&gt;
    END;                                                              &lt;BR /&gt;
  END;                                                                &lt;BR /&gt;
  ELSE DO;    &lt;BR /&gt;
    ABORT RETURN 4;&lt;BR /&gt;
  END;             &lt;BR /&gt;
 STOP;             &lt;BR /&gt;
 RUN;              &lt;BR /&gt;
&lt;BR /&gt;
Again, thanks everyone and I will keep in touch!&lt;BR /&gt;
&lt;BR /&gt;
G.I. Jeff</description>
      <pubDate>Wed, 12 Jan 2011 14:45:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61267#M17392</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2011-01-12T14:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61268#M17393</link>
      <description>It's not a contest but I'm glad my program was helpful.&lt;BR /&gt;
&lt;BR /&gt;
You can simplify the program a bit if you don't need the macro variable by creating the FILENAME in the data step that reads the file.&lt;BR /&gt;
&lt;BR /&gt;
[pre]FILENAME = cats('SYS90H.LNXMEM.D',put(today()+1,yymmddn6.));[/pre]&lt;BR /&gt;
&lt;BR /&gt;
If you need the macro variable with the date+1 that could be done in the same data step too.</description>
      <pubDate>Wed, 12 Jan 2011 16:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61268#M17393</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-01-12T16:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61269#M17394</link>
      <description>Thanks for your suggestion.&lt;BR /&gt;
&lt;BR /&gt;
Wasn't making a contest, just trying to be funny.</description>
      <pubDate>Thu, 13 Jan 2011 15:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61269#M17394</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2011-01-13T15:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61270#M17395</link>
      <description>I knew you were making a joke.  I'm glad to be the winner &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
Are you a G.I. as in serving in the Armed Forces?</description>
      <pubDate>Thu, 13 Jan 2011 16:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61270#M17395</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-01-13T16:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61271#M17396</link>
      <description>I used to be in the Navy, 90-94. Got out, went to college, got my tech degree, thought it would be fun to be a programmer, went to work for Hallmark Cards, left to go to Yellow Freight trucking company and recently just aquired a job with the federal government working for the USDA. I actually was programming before I joined the Navy and came back to it. I love it. I'm a mainframer for life, one of the youngest in Kansas City.&lt;BR /&gt;
&lt;BR /&gt;
Got a new dillema with your suggested code:&lt;BR /&gt;
I tried it with a different file, non-comma seperated file, and now the same code seems to be looping.&lt;BR /&gt;
&lt;BR /&gt;
&lt;B&gt;OPTIONS NOERRABEND;                                                 &lt;BR /&gt;
                                                                    &lt;BR /&gt;
DATA LNX_USERS;                                                     &lt;BR /&gt;
                                                                    &lt;BR /&gt;
 LENGTH FILENAME $256;                                              &lt;BR /&gt;
 FILENAME = CATS('SYS90H.SYSE.USERLOG.D',PUT(TODAY()-1,YYMMDDN6.)); &lt;BR /&gt;
                                                                    &lt;BR /&gt;
  IF FILEEXIST(FILENAME) THEN DO;                                   &lt;BR /&gt;
                                                                    &lt;BR /&gt;
   INFILE DUMMY END=EOF FILEVAR=FILENAME MISSOVER;                  &lt;BR /&gt;
    DO WHILE(NOT EOF);                                              &lt;BR /&gt;
                                                                    &lt;BR /&gt;
       INPUT                                                        &lt;BR /&gt;
       @1    RECTYPE  $1.                                           &lt;BR /&gt;
       @2    LNXUSER  $8.                                           &lt;BR /&gt;
       @13   LNXTIME  TIME.                                         &lt;BR /&gt;
       @25   CPU      4.0                                           &lt;BR /&gt;
       @31   TOTCPUT  5.0                                           &lt;BR /&gt;
       @37   VRTCPUT  5.0                                           &lt;BR /&gt;
       @45   CPURATIO 3.0                                           &lt;BR /&gt;
       @51   VRTIO    4.0                                           &lt;BR /&gt;
       @57   TOTIO    4.0                                           &lt;BR /&gt;
       @82   PAGESEC  4.0                                           &lt;BR /&gt;
       @138  WEIGHT   3.0                                           &lt;BR /&gt;
       @144  VCPUS    1.0;                                          &lt;BR /&gt;
                                                                    &lt;BR /&gt;
       IF RECTYPE NE 'U' THEN DELETE;                               &lt;BR /&gt;
       LNXDATE=TODAY()-1;                                           &lt;BR /&gt;
       SYSTEM='SYSE';                                               &lt;BR /&gt;
                                                                    &lt;BR /&gt;
    OUTPUT;                                                         &lt;BR /&gt;
    END;                                                            &lt;BR /&gt;
  END;                                                              &lt;BR /&gt;
  ELSE DO;                                                          &lt;BR /&gt;
    ABORT RETURN 4;                                                 &lt;BR /&gt;
  END;                                                         &lt;BR /&gt;
STOP;&lt;BR /&gt;
RUN;&lt;/B&gt;      &lt;BR /&gt;
&lt;BR /&gt;
I removed the delimiter, dsd and firstobs options from the INFILE statement and added the MISSOVER (after several attempt thinking it might be missing values) and it still doesn't end. This new file has 143k rows but if I feed it the old way I used to, it only took less than a minute to run.&lt;BR /&gt;
&lt;BR /&gt;
It's almost like it's not reaching the END=EOF condition. Is there something that I can write to the SASLOG that will tell me if it's stuck processing the same record or looping through the entire file? Could it be the FILEVAR statement? I've read up on it and it sounds like a placeholder variable for reading multiple files (which is what I want to do with this job, but just trying 1 file for now) but doesn't really sound like a culprit.&lt;BR /&gt;
&lt;BR /&gt;
Jeff</description>
      <pubDate>Thu, 13 Jan 2011 20:44:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61271#M17396</guid>
      <dc:creator>G_I_Jeff</dc:creator>
      <dc:date>2011-01-13T20:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61272#M17397</link>
      <description>You might insert something like this between your two END statements:&lt;BR /&gt;
[pre]&lt;BR /&gt;
outer_loop+1 ;&lt;BR /&gt;
putlog outer_loop= ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
O.k., I'm just guessing but I think a STOP statement between the ENDs might help.</description>
      <pubDate>Fri, 14 Jan 2011 07:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61272#M17397</guid>
      <dc:creator>Robert_Bardos</dc:creator>
      <dc:date>2011-01-14T07:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling for missing file using FILENAME statement.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61273#M17398</link>
      <description>The problem is with the DELETE statement.  It sends the program back to the top of the data step.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
IF RECTYPE NE 'U' THEN DELETE; &lt;BR /&gt;
LNXDATE=TODAY()-1; &lt;BR /&gt;
SYSTEM='SYSE'; &lt;BR /&gt;
OUTPUT; &lt;BR /&gt;
END; &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
You can change DELETE to CONTINUE and get the desired result.&lt;BR /&gt;
&lt;BR /&gt;
Also, since LNXDATE and SYSTEM are constants move those statements to the top of the data step so they are only executed once.&lt;BR /&gt;
&lt;BR /&gt;
Just for good measure put a stop at the end of the step that will always execute, you want this step to stop when it gets to the bottom in all cases.  In this data step _N_ should never be greater than 1.&lt;BR /&gt;
&lt;BR /&gt;
I used mainframes for many years.  You had to if you used SAS, in the 70s.  I always enjoyed using mainframes and never understood those who thought otherwise.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your service!</description>
      <pubDate>Fri, 14 Jan 2011 12:07:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Error-handling-for-missing-file-using-FILENAME-statement/m-p/61273#M17398</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2011-01-14T12:07:46Z</dc:date>
    </item>
  </channel>
</rss>

