sas: csv file has spaces before the comma but outside the quotes

前端 未结 1 1287
渐次进展
渐次进展 2021-01-23 08:43

A csv file I am trying to read with SAS has spaces between fields with double quotes.

example:

\"ok\",\"bad spaces ahead\"        ,\"more data\"  
__________         


        
相关标签:
1条回答
  • 2021-01-23 09:34

    adding dsd and missover in your infile statement works?

    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;
    

    from the log:

    xok x
    xbad spaces ahead x
    xmore data x
    
    xok x
    xno spaces ahead x
    xmore data x
    
    0 讨论(0)
提交回复
热议问题