CHEBURASHKA
CHEBURASHKA

Reputation: 1713

How to manipulate an external file using SAS?

I have an external .html file . I need to make some changes

I want to substitute all text that lies in between <head> and <thead> with my own script . It is a very straightforward task for any programming language like Java or C . I have no idea how to do this with SAS . I mean maximum record length for SAS is 32K or so , but my .html file is a way larger than that. Please help me . There must be a way

Upvotes: 0

Views: 111

Answers (1)

Laurent de Walick
Laurent de Walick

Reputation: 2174

You don't need to read the HTML file into one field. You can just read word by word and skip the part between <head> and <thead>.

data _null_;
 length ln $32000;
 infile 'in.html' lrecl=32000 line=nl;
 file 'out.html';
 input ln @@;
 if index(ln ,"<head") gt 0 then do;
  ln = substr(ln ,1,index(ln ,'>'));
  if nl=2 then put;
  put ln ;
  put 'put what you want to insert here';
  put 'and more after a second put if it is too large';
  do while (index(ln ,"<thead>") eq 0); 
   input ln @@;
  end;
 end;
 if nl=2 then put;
 put ln @@;
run;

Upvotes: 2

Related Questions