Date: Tue, 8 May 2007 16:03:22 -0400
Reply-To: Lorne Klassen <lk1@ROGERS.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Lorne Klassen <lk1@ROGERS.COM>
Subject: Check if a file exists in concatented aggregate fileref
SAS 9.1, Windows XP
I want to check if a file exists in a folder. If the fileref for my folder
is a fileref pointing to a *single* folder then this works:
filename xxx "c:\a";
/*************************************************************************/
/* Assign a sys generated fileref to the file x2.txt in the folder c:\a */
/*************************************************************************/
%let tempfref = ;
%let rc = %SYSFUNC(FILENAME(tempfref,x2.txt,DISK,,xxx));
/***********************************/
/* Check if the file x2.txt exists */
/* THIS WORKS FINE */
/***********************************/
%let exist = %SYSFUNC(FEXIST(&tempfref));
%put ∃
HOWEVER......
If the aggregate fileref is a fileref of concatenated folders then this
does not work:
filename xxx ("c:\a", "c:\b", "c:\c");
/**************************************************************/
/* Assign a sys generated fileref to the file x2.txt in <xxx> */
/**************************************************************/
%let tempfref = ;
%let rc = %SYSFUNC(FILENAME(tempfref,x2.txt,DISK,,xxx));
/****************************************************************/
/* This time FEXIST always returns 1, even if the file does not */
/* exist in any of the 3 folders */
/****************************************************************/
%let exist = %SYSFUNC(FEXIST(&tempfref));
%put ∃
Note: Using tempfref to read from x2.txt works
Does anyone know how to check if x2.txt exists in the concatenated fileref
xxx (i.e. in one or more of the three folders)?