data readrtf_a;
infile "E:\sas_study\programs\test.rtf" missover length = l end = lastobs lrecl = 2000;
input string $varying2000. l;
rownum = _n_;
string=tranwrd(string, '{\field{\*\fldinst SYMBOL 179 \\f "Symbol" }}', '>=');
string=tranwrd(string, '{\super a} ' , '');
retain c1-c99 dropme indent;
length c1-c2 $200 c3-c99 $50;
if _n_ = 1 then dropme = 1;
array c{99} $;
if index(string, '\trowd') then do;
count = 0;
indent = 0;
do i=1 to dim(c);
c{i} = '';
end;
end;
if index(string, '{') and index(string, '\cell') then do;
count + 1;
prep = substr(string, 1, index(string, '\cell')-1);
prep = scan(prep, 2, '{');
c{count} = compress(prep, byte(13));
if count = 1 then do;
sst = substr(string, index(string, '\li') + 3);
if verify(sst, '-0123456789') > 1 then
indent=input(substr(sst, 1, verify(sst, '-0123456789') - 1), best.);
end;
if index(c{count}, '\li') then do;
c{count} = substr(c{count}, index(c{count}, '\li'));
c{count} = substr(c{count}, index(c{count}, ' ')+1);
end;
end;
if dropme = 4 then dropme = 0;
if index(string, '\sect') or
(index(compress(lowcase(string)), 'page') and
index( lowcase(string) , ' of ')) then dropme = 1;
else if index(string, '\trowd' ) and dropme = 1 then dropme = 2;
else if index(string, '\clbrdrb') and dropme = 2 then dropme = 3;
else if index(string, '\row' ) and dropme = 3 then dropme = 4;
if not dropme and index(string, '\row') then do;
allblank = 1;
do i=1 to dim(c);
if compress(c{i}, ' \') ne '' then allblank = 0;
end;
if not allblank then output;
end;
run;
Thursday, August 12, 2010
SAS
Subscribe to:
Posts (Atom)