I have troubles reading CSV files in with the following situation occurs: <xx><delim><quote><……..><quote><delim><delim><xx>. So some ware in a recordline there is a delimiter, followed with a quote, then one or more fields, then some characters closed with a quote before the next delimiter. I tried to solve it with the DSD option but that doesn’t work. The DSD skips the delimiter between the quotes. Without DSD two delimiters behind each others are transformed to one delimiter. Double delimiters can occur because it represents a missing value for that variable. The problem is the last quote directly followed by a delimiter. Who can help me to solve this problem? Following below are two identical examples. The first is with DSD, the second without. * Infile with DSD. Record 3 (KEY='C') fails because the string 's Gravenhage,Mataw' leads to one variable;
data work.OPER_A_DSD;
infile datalines delimiter = "," MISSOVER DSD;
attrib KEY length = $12;
attrib CITY length = $60;
attrib NAME length = $50;
attrib EMPTY length =$1;
attrib EX length = $1;
input KEY CITY NAME EMPTY EX $;
put _all_;
datalines;
A,Utrecht,James,,X
B,'s Gravenhage,Scott,N,X
C,'s Gravenhage,Mataw',N,X
D,'s Gravenhage,Mataw',,X
E,'s Gravenhage,Mata'w,,X
;
run;
* Infile without DSD. Record 1 (KEY='A') fails because 2 cancatenated delimitters (,,) is converted to one. The value X is placed in the variable EMPTY instead of EX;
data work.OPER_A_NODSD;
infile datalines delimiter = "," MISSOVER ;
attrib KEY length = $12;
attrib CITY length = $60;
attrib NAME length = $50;
attrib EMPTY length =$1;
attrib EX length = $1;
input KEY CITY NAME EMPTY EX $;
put _all_;
datalines;
A,Utrecht,James,,X
B,'s Gravenhage,Scott,N,X
C,'s Gravenhage,Mataw',N,X
D,'s Gravenhage,Mataw',,X
E,'s Gravenhage,Mata'w,,X
;
run;
... View more