你需要一個(0)
添加到您的close語句。這告訴它不要提示。
data _null_;
file commands;
put "[Save.as(""&saveas_Path.&saveas..xls"")]";
put "[Close(0)]";
run;
這是我的全部宏(解釋一些文檔類型參數):
/******************************************************************************
** PROGRAM: MACRO.DDE_SAVE_AS.SAS
**
** DESCRIPTION: SAVES THE CURRENT EXCEL FILE. IF THE FILE
** ALREADY EXISTS IT WILL BE OVERWRITTEN.
**
** PARAMETERS: iSAVEAS: THE DESTINATION FILENAME TO SAVE TO.
** iType : (OPTIONAL. DEFAULT=BLANK).
** BLANK = XL DEFAULT SAVE TYPE
** 1 = XLS DOC - OLD SCHOOL! PRE OFFICE 2007?
** 44 = HTML - PRETTY COOL! CHECK IT OUT...
** 51 = XLSX DOC - OFFICE 2007 ONWARDS COMPATIBLE?
** 57 = PDF
**
** NOTES: IF YOU ARE GETTING A DDE ERROR WHEN RUNNING THIS MACRO THEN DOUBLE
** CHECK YOU HAVE PERMISSIONS TO SAVE WHERE YOU ARE TRYING TO SAVE THE
** FILE.
**
*******************************************************************************
** VERSION:
** 1.0 ON: 01APR10 BY: RP
** CREATED.
******************************************************************************/
%macro dde_save_as(iSaveAs=,iType=);
%local iDocTypeClause;
%let iDocTypeClause=;
%if "&iType" ne "" %then %do;
%let iDocTypeClause=,&iType;
%end;
filename cmdexcel dde 'excel|system';
data _null_;
file cmdexcel;
put '[error(false)]';
put "%str([save.as(%"&iSaveAs%"&iDocTypeClause)])";
put '[error(true)]';
run;
filename cmdexcel clear;
%mend;
/*%dde_save_as(iSaveAs=d:\rrobxltest, iType=44);*/
謝謝你來搶!我會放棄這一點。 – Adam 2012-02-09 15:35:02
嗨,我今天來問題。如果我想關閉excel文件而不保存它呢?關閉(0)似乎不起作用。 – useR 2014-11-25 08:38:27
@useR'close(0)'確實有效。這段代碼會這樣做:'filename cmdexcel dde'excel | system'; data _null_; 文件cmdexcel; put'[close(0)]'; 跑; 文件名cmdexcel清除;' – 2014-11-25 16:28:34