Date: Fri, 1 Oct 2004 11:27:07 +0200
Reply-To: Robert Bardos <bardos2@ANSYS.CH>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Robert Bardos <bardos2@ANSYS.CH>
Subject: Re: Checking filenames
In-Reply-To: <24410121.0410010022.464d864e@posting.google.com>
Content-Type: text/plain; charset="iso-8859-1"
Rune,
regarding your first question:
the %SCAN function has as its third argument a set of delimiter characters
which by default consists of
blank . < ( + & ! $ * ) ; ^ - / , % |
As you see the dot "." is part of these delimiters. Specifying e.g.
%let file = %scan(&file_list,&i,%str( ));
might give you want you want. Note that this technique fails when your
filenames contain blanks themselves.
Hope this helps
Robert Bardos
Ansys AG, Switzerland
-----Ursprüngliche Nachricht-----
Von: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]Im Auftrag von
Rune Runnestoe
Gesendet: Freitag, 1. Oktober 2004 10:22
An: SAS-L@LISTSERV.UGA.EDU
Betreff: Re: Checking filenames
Hi,
When running this code:
%macro test (file_list , num_of_files);
%do i = 1 %to &num_of_files;
%let file = %scan(&file_list,&i);
%if %sysfunc(fileexist(D:\rune\&file)) %then
%put The file &file exists.;
%else
%put File &file does not exist.;
%end;
%mend;
%test(SAK DOK NOFILE, 3);
The output in the log is:
The file SAK exists.
The file DOK exists.
File NOFILE does not exist.
But when I change the filenames to SAK.DAT, DOK.DAT and NOFILE.DAT,
then I get this:
%macro test (file_list , num_of_files);
%do i = 1 %to &num_of_files;
%let file = %scan(&file_list,&i);
%if %sysfunc(fileexist(D:\rune\&file)) %then
%put The file &file exists.;
%else
%put File &file does not exist.;
%end;
%mend;
%test(SAK.DAT DOK.DAT NOFILE.DAT, 3);
From the log:
File SAK does not exist.
File DAT does not exist.
File DOK does not exist.
<rest snipped>