home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / bit / listserv / sasl / 5070 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.2 KB  |  60 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!stanford.edu!bcm!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!uwm.edu!psuvax1!psuvm!auvm!SWIRL.MONSANTO.COM!GIBES
  3. Message-ID: <9211171640.AA26460@tin.monsanto.com>
  4. Newsgroups: bit.listserv.sas-l
  5. Date:         Tue, 17 Nov 1992 10:40:34 -0600
  6. Reply-To:     Kernon Gibes <gibes@SWIRL.MONSANTO.COM>
  7. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. From:         Kernon Gibes <gibes@SWIRL.MONSANTO.COM>
  9. Subject:      RE: missing ascii files and macro
  10. Comments: To: SAS-L@uga.cc.uga.edu@tin.monsanto.com
  11. Comments: cc: GIBES@tin.monsanto.com
  12. Lines: 46
  13.  
  14.  CONTENT:   Response (to Okerson's macro quesiton)
  15.  SUMMARY:   Try using VMS FINDFILE function is a separate data step
  16.  REL/PLTF:  6.06+/VMS
  17.  E-ADDR:    gibes@swirl.monsanto.com
  18.  NAME:      Kernon Gibes
  19.  DATE:      17 November 1992
  20.  
  21. Barbara Okerson asks:
  22.  
  23. >I have a user who has several hundred ascii files that he needs to read in to
  24. >process with SAS and he has a macro to do this.  The file names are mainly
  25. >sequential but there are some numbers that there is no ascii file for.  In the
  26. >macro when SAS reaches a value of the infile statement that is not there, SAS
  27. >quits processing rather than printing an error and going on to the next
  28. <stuff delelted>
  29. >if data set a8.dat is missing, for example, SAS will quit processing.  Because
  30. >of the type of data there will be some missing runs, but renumbering is not
  31. >really a solution because the numbers identify the runs.
  32. >
  33. >Please tell me there is an obvious solution and I am just overlooking it.
  34.  
  35. One solution is given below.  It uses a separate data _NULL_ step to
  36. ascertain whether the external file exists.  I don't make any claims that
  37. this is an "obvious" or the simplest solution.
  38.  
  39. +---Example--------------------------------------------------------------+
  40.  
  41.    %macro test (prefix=a, number=10 );
  42.      %do i = 1 %to &number;
  43.        %let found = 0;
  44.        data _null_;
  45.            context = 0;
  46.            fn = findfile( "&prefix&i..dat", context );
  47.            if fn ^= ' ' then call symput( 'found', '1' );
  48.            stop;
  49.         run;
  50.       %if &found = 1 %then %do;
  51.         data test;
  52.          infile "&prefix&i";
  53.          input a b c;
  54.         run;
  55.       %end;
  56.     %end;
  57.    %mend;
  58.  
  59.   %test;
  60.