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屋!