在 SAS 中抑制 HTML 输出 [英] Suppressing HTML output in SAS
问题描述
我试图抑制 HTML 输出并使 PROC PRINT
仅输出到 CSV,但 ODS HTML Close
似乎不起作用.
I'm trying to suppress HTML output and get PROC PRINT
to output only to CSV, but ODS HTML Close
doesn't seem to work.
我的代码是:
ODS HTML close;
ODS CSV file="\\..output folder..\filename.csv";
proc print data=test;
run;
ODS CSV close;
ODS HTML;
推荐答案
你的方法看起来有点奇怪,为什么要求助于 ods csv?SAS 有一个 proc 导出程序:
Your approach seems a bit odd, why resort to ods csv? SAS has a proc export procedure:
proc export data=test outfile="\\..output folder..\filename.csv" dbms=CSV replace;
run;
您可以进一步将其配置为具有不同的分隔符、无标题等:http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000393174.htm
You can further configure it to have a different delimiter, no headers etc.: http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000393174.htm
编辑回复您的评论:我看到有两种方法可以解决阻止您尝试 proc 导出的问题.
EDIT In reply to your comment: i see two ways around the issues that keep you from trying proc export.
第一种方法是将 validvarname 设置为 ANY,这让您可以自由选择变量名.例如:
The first approach is setting the validvarname to ANY, which gives you great liberty in choosing variable names. E.g.:
options validvarname=ANY;
data test;
'Column Header Text I Want'n=1; output;
'Column Header Text I Want'n=5; output;
run;
proc export data=test outfile="\\..output folder..\filename.csv" dbms=CSV replace;
run;
就我个人而言,我不喜欢上述方法,因为我发现当您不再有一些变量命名规则时,它会导致代码更难阅读.
Personally, i'm not a fan of the above approach, since i find that it leads to harder-to-read code when you no longer have some naming rules for variables.
第二种方法——我更喜欢——是用你想要的文本标记变量,并将标签选项放在你的 proc 导出上.例如:
A second approach - which i prefer - is to label the variable with the text you want it to have and put the label option on your proc export. E.g.:
data test;
label variable_name='Column Header Text I want';
variable_name=1; output;
variable_name=5; output;
run;
proc export data=test outfile="\\..output folder..\filename.csv" dbms=CSV replace LABEL;
run;
请注意,输出中有一个小区别:第一种方法不会在列名周围加上引号,而第二种方法会这样做.
Note that there is a small distinction in the output: the first approach will not put quotes around your column names while the second approach will do that.
最后,在自己做一些额外的阅读时,我偶然发现了这一点,这可能对您也有帮助:http://www.sascommunity.org/wiki/Create_a_CSV_file_without_column_names/headers_in_row_1#DATA_NULL_with_a_PUT_statement.2C_all_fields_quoted
Finally, while doing some extra reading myself, i stumbled across this, which may be of help to you as well: http://www.sascommunity.org/wiki/Create_a_CSV_file_without_column_names/headers_in_row_1#DATA_NULL_with_a_PUT_statement.2C_all_fields_quoted
这篇关于在 SAS 中抑制 HTML 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!