?
Solved

Delete an external file

Posted on 2011-02-16
3
Medium Priority
?
576 Views
Last Modified: 2013-11-16
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

0
Comment
Question by:sonmic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Expert Comment

by:theartfuldazzler
ID: 34906607
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

0
 
LVL 11

Accepted Solution

by:
theartfuldazzler earned 2000 total points
ID: 34906619
PS - if you change the first line to:

%l;et work = c:\Data;

then you should have the equivalent code.
0
 
LVL 14

Expert Comment

by:Aloysius Low
ID: 34906771
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
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question