Link to home
Start Free TrialLog in
Avatar of sonmic
sonmic

asked on

Delete an external file

Hi,

Code below will not work. Can't find the problem.

Tx
DATA _NULL_ ;
    %LET XX1 = c:\Data\xx1.xls ;
    %LET XX2 = c:\Data\xx2.xls ;
    %LET XX3 = c:\Data\xx3.xls ;
RUN ;

%MACRO checkFile (bestand = ) ;
    %IF %SYSFUNC(fileexist(&bestand)) = 0 %THEN %DO ;
	%END ;
    %ELSE %DO ; 
    	FILENAME MFile &bestand  ;
         DATA _NULL_ ;
	   rc = FDELETE(&bestand) ;
	RUN ;

	FILENAME &bestand CLEAR ;
	%END ;
%MEND checkFile ;

%checkFile(bestand = &xx1) ;
%checkFile(bestand = &xx2) ;
%checkFile(bestand = &xx3) ;

Open in new window

Avatar of theartfuldazzler
theartfuldazzler
Flag of South Africa image

Hi

A few problems, mostly linked to quotation marks.
 
%Let work = %SYSFUNC(PATHNAME(WORK));
%put &work;

DATA _NULL_ ;
    %LET XX1 = "&work\xx1.xls" ;
    %LET XX2 = "&work\xx2.xls" ;
    %LET XX3 = "&work\xx3.xls" ;
RUN ;

%MACRO checkFile (bestand = ) ;
    %IF %SYSFUNC(fileexist(&bestand)) = 0 %THEN %DO ;
	%END ;
    %ELSE %DO ; 
	    
    	FILENAME MFile &bestand  ;
         DATA _NULL_ ;
	   rc = FDELETE("MFILE") ;
	RUN ;

	FILENAME MFILE CLEAR ;
	%END ;
%MEND checkFile ;
options mprint;
%checkFile(bestand = &xx1) ;
%checkFile(bestand = &xx2) ;
%checkFile(bestand = &xx3) ;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of theartfuldazzler
theartfuldazzler
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aloysius Low
if after trying what theartfuldazzler has said and is still not working, please post the log.

it's always easier to look at the log and help