我想寫一個SAS程序來查找並通過DDE在Excel文件中進行替換。具體來說,我試圖在標題行中搜索字符串之間的空格(即「」),並將它們替換爲無空格(即「」)。SAS - 通過DDE在Excel文件中執行查找和替換
例如,如果我有一個單元格包含「測試名稱」我想要做一個查找並替換,使其「TestName」。
這是我有:
options noxwait noxsync;
/* Open Excel */
x '"C:\Program Files (x86)\Microsoft Office\Office14\excel.exe"';
filename cmds dde 'excel|system';
data _null_;
x=sleep(5);
run;
/* Open File and Manipulate*/
data _null_;
file cmds;
put '[open("C:\filename.xls")]';
put '[select("R1")]';
put '[formula.replace(" ","",1,,false,false)]';
run;
/*Close File*/
data _null_;
file cmds;
put '[FILE-CLOSE("C:\filename.xls")]';
put '[QUIT()]';
run;
查找和替換功能無法正常工作。在我的日誌中讀到以下聲明後,我得到以下內容:
NOTE: The file CMDS is:
DDE Session,
SESSION=excel|system,RECFM=V,LRECL=256
ERROR: DDE session not ready.
FATAL: Unrecoverable I/O error detected in the execution of the DATA step program.
Aborted during the EXECUTION phase.
NOTE: 2 records were written to the file CMDS.
The minimum record length was 21.
The maximum record length was 70.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.63 seconds
cpu time 0.00 seconds
有什麼建議嗎?
另外,有沒有人知道formula.replace語句中的參數是什麼?我只知道第一個和第二個是你想要找到的以及你想要替換的東西。我正在努力尋找任何文件。
這就是我剛纔的結論。 – ESmith5988 2013-05-09 17:55:42