我的印象是,在SAS 9.3中,可以在HTML输出文件中嵌入SVG图表=> SAS page on SVG output
但是,在Linux服务器上尝试以下简单示例始终会生成带有外部PNG文件的HTML文件。
ods listing close;
options device=svg;
ods graphics / outputfmt=svg reset=all;
ods html path="~" file="01_output.html";
proc sgplot data=sashelp.class;
scatter x=height y=weight;
ellipse x=height y=weight;
run;
ods html close;
ods listing;
有谁知道如何在SAS中嵌入HTML格式?
答案 0 :(得分:1)
您需要将reset=all
移动到ODS GRAPHICS语句的开头,或将其删除。您将格式设置为SVG,然后重置它。以下内容适用于我的机器(9.3 Windows),而您的代码生成了PNG。
ods listing close;
options device=svg;
ods graphics / outputfmt=svg;
ods html path="c:\temp\" file="01_output.html";
proc sgplot data=sashelp.class;
scatter x=height y=weight;
ellipse x=height y=weight;
run;
ods html close;
ods listing;
要一步完全嵌入HTML文件,您需要使用9.4并使用ods html5
,它会自动嵌入svg。那里options device=svg
是不必要的。
答案 1 :(得分:0)
编辑:以下仅适用于SAS 9.3及之前版本。有关如何在v9.4及更高版本中执行此操作,请参阅Joe上面选择的答案。
是的,可以将SVG嵌入到.html文件中,但不能使用ODS在一个步骤中完成。 ODS总是将SVG(或图像)生成一个单独的文件,然后生成它生成的.html文件,你需要自己将它们联合起来。
关于使用SVG的这篇文章篇幅很长但很好:
http://css-tricks.com/using-svg/
这个问题也非常有用:
Do I use <img>, <object>, or <embed> for SVG files?
这是一个管道磁带示例(感谢Joe,其代码我稍作修改):
ods listing close;
options device=svg;
ods graphics / outputfmt=svg;
ods html path="%sysfunc(pathname(work))" file="whatever.html";
proc sgplot data=sashelp.class;
scatter x=height y=weight;
ellipse x=height y=weight;
run;
ods html close;
ods listing;
下面创建一个名为embedded.html
的新HTML文件,其中包含一个非常简单的.html文件。它只是获取SVG文件的内容并将其放在文件的中间。
因为SVG实际上只是XML现代浏览器应该运行良好(但请参阅上面的链接,了解如何在旧浏览器中使用它)。
data _null_;
file "%sysfunc(pathname(work))\embedded.html";
infile "%sysfunc(pathname(work))\SGPlot1.svg" end=eof;
if _n_ eq 1 then do;
put "<html><body>";
end;
input;
put _infile_;
if eof then do;
put "</body></html>";
end;
run;
您还在评论中提到,您可能希望对其他类型的文档也执行相同的操作,例如PDF / RTF。如果是这样,可能值得发布一个新问题,因为你必须在base64中对事物进行编码才能实现这一目标,而且这不是一项微不足道的工作。