如何使用proc print将此代码的结果打印到html中?这是因为我必须将代码集成到仅使用proc print的现有代码中。提前谢谢!
filename cmd pipe "dir G:\ | findstr /c:""bytes free""";
data _null_;
infile cmd;
input;
free_space_gb = input(scan(_infile_,3,' '), comma20.) * 2**-30;
put "There is currently " free_space_gb 8.2 "GB of free space on the G
drive";
call symput('free_space_gb',free_space_gb); /*Create macro variable*/
run;
%macro print_alert_html;
%if &free_space_gb < 1 %then %do;
ods listing close;
ods html file = "%sysfunc(pathname(work))\report.html";
ods html text = "Alert: only &free_space_gb GB of space left on the G
drive!";
ods html close;
ods listing;
%end;
%mend;
答案 0 :(得分:1)
如果需要使用Proc PRINT,则需要将Gb信息保存在数据集中。您可能希望在输出状态消息时使用Proc REPORT,因为它具有NOHEADER选项。
只有当Gb <&lt;时,REPORT where子句才会导致输出。 1.
filename cmd pipe "dir G:\ | findstr /c:""bytes free""";
data message;
infile cmd;
input;
free_space_gb = input(scan(_infile_,3,' '), comma20.) * 2**-30;
message = "There is currently " || strip(put(free_space_gb, 8.2)) || "GB of free space on the G drive";
run;
%macro print_alert_html;
ods listing close;
ods html file = "%sysfunc(pathname(work))\report.html";
title;
footnote;
options nocenter nodate nonumber;
proc report data=message noheader;
column message;
where free_space_gb < 1.00;
run;
ods html close;
ods listing;
%mend;
%print_alert_html;