我正在尝试编写一个应该创建多个外部html
文件的宏。这是我的代码
%macro createFiles;
%let name = Jupiter*Mercury*Venus;
%let htmlTxt1 = <html><h1>Hello To ;
%let htmlTxt2 = </h1></html> ;
%let i = 1 ;
%let thisName = %scan(&name., &i.,"*") ;
%do %while (&thisName. ne ) ;
filename thisFile "C:\Users\owner\Desktop\&thisName.html";
call execute ('data _null_; file &thisFile; put &htmlTxt1 || &thisName || &htmlTxt2; run; ') ;
%let i = %eval(&i + 1 ) ;
%let thisName = %scan(&name.,&i.,"*");
%end ;
%mend ;
%createFiles
然而,它不起作用。请帮帮我
谢谢
答案 0 :(得分:1)
主要是拼写错误和语法错误的组合。 SAS也有ODS HTML目的地,在我看来,它更容易用来创建HTML文件。
%macro createFiles;
%let name = Jupiter*Mercury*Venus;
%let htmlTxt1 = <html><h1>Hello To ;
%let htmlTxt2 = </h1></html> ;
%let i = 1 ;
%let thisName = %scan(&name., &i.,"*") ;
%do %while (&thisName. ne ) ;
filename thisFile "C:\temp\&thisName..html";
data _null_;
file thisFile;
put "&htmlTxt1 || &thisName || &htmlTxt2";
run;
%let i = %eval(&i + 1 ) ;
%let thisName = %scan(&name.,&i.,"*");
%end ;
%mend ;
%createFiles