From: Scott Bass on
Hi,

Is there a better way to "clear out" an Excel workbook than deleting the
existing file?

This works, and is my desired output, although not my desired approach:

libname xl "c:\temp\test.xls";

data one two three;
x=1;
run;

proc copy in=work out=xl;
select one three;
run;

libname xl;

* clear out previous output ;
systask command "del c:\temp\test.xls" wait;

libname xl "c:\temp\test.xls";

proc copy in=work out=xl;
select two;
run;

libname xl;


This doesn't work, the *data* in the worksheets are deleted, but not the
worksheet tab:

libname xl "c:\temp\test.xls";

data one two three;
x=1;
run;

proc copy in=work out=xl;
select one three;
run;

* clear out previous output ;
proc datasets lib=xl kill nowarn nolist;
quit;

proc copy in=work out=xl;
select two;
run;

libname xl;


Thanks,
Scott