Reputation: 3099
I am trying to write a macro that should create multiple external html
files . Here is my code
%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
However, it does not work . Please help me
Thanks
Upvotes: 0
Views: 182
Reputation: 21264
Mostly a combination of typo's and syntax errors. SAS also has the ODS HTML destination which would be easier to use to create HTML files in my opinion.
%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
Upvotes: 1