Following the advice provided by @LinusH and @RW9 is highly recommended.
If you can't get a fixed source file, try the following code:
data address2;
infile datalines dsd;
length city $10;
input name $ age city $ gender $;
if countc(_infile_, ',') > 3 then do;
gender = scan(_infile_, 1, ',', 'b');
call scan(_infile_, 3, pos, len, ',');
city = compress(substr(_infile_, pos, findc(_infile_, ',', 'b')-pos), ',');
end;
datalines;
Steve,32,Monona,M
Tom,44,Milwaukee,M
Deb,23,Ma,dison,F
bob,24,Texas,M
Harry,43,flo,rida,M
run;
... View more