|
On Tue, 5 Apr 2005 10:43:10 -0400, Chang Chung <chang_y_chung@HOTMAIL.COM> wrote:
>But nothing's impossible in SAS, it seems. Here is one way -- yeah, it is
>much uglier and it generates a warning "symbolic reference AMP not
>resolved." This means that if you are using any macro variable whose name is
>the same as the name of a HTML entiry, then it will mess up the generated
>code... oh well...
>
>Cheers,
>Chang
Chang:
Here is a less icky, yet still excessive way. It does looping with prxNext, prxChange and TranWrd. Presumes the template does not contain the sequence <resolved>.
data _null_;
infile template;
file resolved;
if _n_ = 1 then
rx = prxParse ('s:<macro>(.*?)</macro>:<resolved>:i');
retain rx;
input;
start = 1; stop = -1;
call prxNext (rx,start,stop,_infile_,pos,len);
do while (pos);
call prxposn (rx,1,xpos,xlen);
expression = substr(_infile_,xpos,xlen);
expressionResolved = resolve (expression);
call prxChange (rx,1,_infile_);
_infile_ = tranwrd (_infile_, '<resolved>', trim(expressionResolved));
start = pos + length(expressionResolved);
call prxNext (rx,start,stop,_infile_,pos,len);
end;
put _infile_;
run;
|