home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!stanford.edu!bcm!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!uwm.edu!psuvax1!psuvm!auvm!SWIRL.MONSANTO.COM!GIBES
- Message-ID: <9211171640.AA26460@tin.monsanto.com>
- Newsgroups: bit.listserv.sas-l
- Date: Tue, 17 Nov 1992 10:40:34 -0600
- Reply-To: Kernon Gibes <gibes@SWIRL.MONSANTO.COM>
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: Kernon Gibes <gibes@SWIRL.MONSANTO.COM>
- Subject: RE: missing ascii files and macro
- Comments: To: SAS-L@uga.cc.uga.edu@tin.monsanto.com
- Comments: cc: GIBES@tin.monsanto.com
- Lines: 46
-
- CONTENT: Response (to Okerson's macro quesiton)
- SUMMARY: Try using VMS FINDFILE function is a separate data step
- REL/PLTF: 6.06+/VMS
- E-ADDR: gibes@swirl.monsanto.com
- NAME: Kernon Gibes
- DATE: 17 November 1992
-
- Barbara Okerson asks:
-
- >I have a user who has several hundred ascii files that he needs to read in to
- >process with SAS and he has a macro to do this. The file names are mainly
- >sequential but there are some numbers that there is no ascii file for. In the
- >macro when SAS reaches a value of the infile statement that is not there, SAS
- >quits processing rather than printing an error and going on to the next
- <stuff delelted>
- >if data set a8.dat is missing, for example, SAS will quit processing. Because
- >of the type of data there will be some missing runs, but renumbering is not
- >really a solution because the numbers identify the runs.
- >
- >Please tell me there is an obvious solution and I am just overlooking it.
-
- One solution is given below. It uses a separate data _NULL_ step to
- ascertain whether the external file exists. I don't make any claims that
- this is an "obvious" or the simplest solution.
-
- +---Example--------------------------------------------------------------+
-
- %macro test (prefix=a, number=10 );
- %do i = 1 %to &number;
- %let found = 0;
- data _null_;
- context = 0;
- fn = findfile( "&prefix&i..dat", context );
- if fn ^= ' ' then call symput( 'found', '1' );
- stop;
- run;
- %if &found = 1 %then %do;
- data test;
- infile "&prefix&i";
- input a b c;
- run;
- %end;
- %end;
- %mend;
-
- %test;
-