From: Bill McKirgan on
I have a situation where I need to use DDE to open excel files prior to
running proc import to read data because the first line of data for the
8th column begins after line 800 (if the files are closed then column 8
is ignored).

I can open the excel files and read the data now using DDE, but I
cannot figure-out how to close the file I opened. I do not want to
save the file that was opened, or save as another file. I simply want
to close it after all 8 columns have been read by proc import.

Thanks in advance,
Bill McKirgan


Here is my test code...


options noxwait noxsync;
x 'c:\temp\excel_test.xls';

PROC IMPORT OUT= WORK.TEST1dde
DATAFILE= "c:\temp\excel_test.xls"
DBMS=EXCEL REPLACE;
SHEET="Sheet1$";
GETNAMES=no;
MIXED=yes;
SCANTEXT=YES;
USEDATE=YES;
SCANTIME=YES;
RUN;



/* Quit Excel using DDE. */
data _null_;
file "c:\temp\excel_test.xls" ;
put "[quit()]";
run;


---log---

266 options noxwait noxsync;
267 x 'c:\temp\excel_test.xls'
267! ; /* you might need to specify */
268 /* the complete pathname */
269
270 run;
271
272 PROC IMPORT OUT= WORK.TEST1dde
273 DATAFILE= "c:\temp\excel_test.xls"
274 DBMS=EXCEL REPLACE;
275 SHEET="Sheet1$";
276 GETNAMES=no;
277 MIXED=yes;
278 SCANTEXT=YES;
279 USEDATE=YES;
280 SCANTIME=YES;
281 RUN;

SYMBOLGEN: Macro variable _IMEXSERROR_ resolves to SERROR
NOTE: WORK.TEST1DDE was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 1.09 seconds
cpu time 0.34 seconds


282 data _null_;
283 file "c:\temp\excel_test.xls" ;
284 put "[quit()]";
285 run;

ERROR: File is in use, c:\temp\excel_test.xls.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds