1
我用下面的代碼將結果導出爲excel文件。但是,每次都會以文件類型輸出結果。我必須手動將其類型更改爲excel。我試過&from.&&memname&i
後放.xls
,但SAS無法識別這種格式。我認爲可能的原因是.x
,但我不怎麼解決這個問題。SAS-使用宏輸出結果爲excel
%macro tradetime(sourcelib=,from=,going=,dir=);
proc sql noprint; /*read datasets in a library*/
create table mytables as
select *
from dictionary.tables
where libname = &sourcelib
order by memname ;
select count(memname)
into:obs
from mytables;
%let obs=&obs.;
select memname
into : memname1-:memname&obs.
from mytables;
quit;
%do i=1 %to &obs.;
ods tagsets.excelxp file= "&Dir\&&memname&i" /*output the results to target file*/
style=XLsansPrinter;
ods listing close;
ods results off;
proc univariate data= &from.&&memname&i;
var time_l_ ;
run;
quit;
ods tagsets.excelxp close;
ods listing ;
ods results on;
%end;
%mend;
%tradetime(sourcelib='AXP',from=AXP.,going=AXP.,dir=D:\Data\description);