sas:csv文件在逗号之前有空格但在引号之外

时间:2010-08-25 17:28:14

标签: csv sas

我试图用SAS读取的csv文件在带双引号的字段之间有空格。

示例:

"ok","bad spaces ahead"        ,"more data"  
_______________________^spaces^____________  


如何让SAS正确阅读?我是否需要更换csv?

1 个答案:

答案 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