我试图用SAS读取的csv文件在带双引号的字段之间有空格。
示例:
"ok","bad spaces ahead" ,"more data" _______________________^spaces^____________
如何让SAS正确阅读?我是否需要更换csv?
答案 0 :(得分:2)
在infile语句中添加dsd和missover有效吗?
data badspaces;
infile datalines dlm=',' dsd missover;
format Var1 $2.
Var2 $20.
Var3 $10.;
input var1-var3;
put 'x' var1 'x'
/ 'x' var2 'x'
/ 'x' var3 'x'
/;
datalines;
"ok","bad spaces ahead" ,"more data"
"ok","no spaces ahead","more data"
run;
来自日志:
xok x
xbad spaces ahead x
xmore data x
xok x
xno spaces ahead x
xmore data x