Hello SAS-users.
I need to read comma delimited file into SAS dataset.
The second character variable "account_name" can contain extra commas
and the next variable "var1" always have values "0" and "1".
My solution is below. But it seems to me a bit awkward.
Could you please suggest something else?
Thanks in advance.
[pre]
data test1 ;
infile datalines truncover dsd;
length account $20. account_name $20. var1 $10. ss_ostd 8. ss_ostc 8. ost_ccy 8. client $10.;
input ;
account=left(scan(_infile_,1,','));
if length(account)=20 then do;
account_name=scan(_infile_,2,',');
var1=trim(left(scan(_infile_,3,',')));
k=4;
do while (trim(left(var1)) not in ('0' '1'));
account_name=trim(account_name)||var1;
var1=trim(left(scan(_infile_,k,',')));
k=k+1;
end;
ss_ostd=input(left(scan(_infile_,k+4,',')),17.);
ss_ostc=input(left(scan(_infile_,k+5,',')),17.);
ost_ccy=input(left(scan(_infile_,k+6,',')),17.);
client=left(scan(_infile_,k+7,','));
end; else delete;
drop k ;
datalines;
20308810700000020292,some text 5,0,6991.53,0.00,0.00,0.00,6991.53,0.00,0,client 1,
20308810000000020293,some,t,ex,t 2,0,6991.53,0.00,0.00,0.00,6991.53,0.00,0,client2,
20308810300000020294,some text 3,1,6991.53,0.00,0.00,0.00,6991.53,0.00,0,client 3,
20308810600000020936,so,me,text,4,0,13440.68,0.00,0.00,0.00,13440.68,0.00,0,client 4,
;
[/pre]