SAS proc 导出到 CSV:如何添加双引号 [英] SAS proc export to CSV: how to add double quotes
问题描述
对此很陌生,所以很抱歉.我在 SAS 中有一个文件,我需要将其导出为 CSV,并且我需要在所有字段中添加双引号.我怎样才能做到这一点?提前致谢.
New to this, so apologies. I have a file in SAS that I need to export as a CSV and I need to add double quotes to all fields. How can I accomplish this? Thanks in advance.
推荐答案
有很多方法可以从 SAS 创建 CSV 文件.使用 proc export
不会将每个字段都用双引号括起来,因此最简单的方法是使用 %ds2csv()
宏.这假设您拥有 SAS 9.2 或更高版本.它的文档可以在这里找到:
There are many ways to create a CSV file from SAS. Using proc export
won't wrap every field in double-quotes, so the easiest one that will do this is the %ds2csv()
macro. This assumes you have SAS 9.2 or later. The documentation for it can be found here:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002683390.htm
运行示例:
%ds2csv(data=sashelp.retail, runmode=b, csvfile=c:class.csv);
生产:
"Retail sales in millions of $","DATE","YEAR","MONTH","DAY"
"$220","80Q1","1980","1","1"
"$257","80Q2","1980","4","1"
"$258","80Q3","1980","7","1"
这篇关于SAS proc 导出到 CSV:如何添加双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!