Date: Mon, 29 Mar 2004 09:47:15 -0700
Reply-To: Alan Churchill <EmailDirect@erratix.us>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Alan Churchill <EmailDirect@ERRATIX.US>
Subject: Re: converting .sas file to .html
Look at HTMLENCODE function.
Alan
"Quentin McMullen" <quentin_mcmullen@BROWN.EDU> wrote in message
news:200403291611.i2TGBHa17163@listserv.cc.uga.edu...
> Thanks much Ed,
>
> The job you sent produces an html file that is formatted more correctly
> (and readably) than what mine spit out, but unfortunately it does not
> achieve any of the symbol protecting/quoting/hiding that I am hoping for.
> For example, if my macro code is:
>
> %macro me(sum=
> ,note=0
> );
> %if ¬e %then %put The sum is ∑
> %if a<b %then %do;
> %end;
> %mend me;
>
> The browser interprets ¬e as being an html symbol ¬ followed by the
> letter 'e', and "∑" is displayed as sigma. And everyting stops after
> a< because the browser takes the '<' as the start of a bad tag. My hope
> was to find a way to quote the sas code so that when viewed in a browser,
> it would look like SAS code.
>
> But working from within your example, it hit me that perhaps the only
> important characters I need to quote are &, <, and >. Is that right? If
> so, than perhaps it is as easy as adding a few calls to tranwrd, e.g.:
>
> Data _null_ ;
> InFile sasCode("junklog.sas") end=eof ;
> File sasCode("junklog.html") ;
> If ( _n_ eq 1 ) then put
> @01 '<!doctype html public "-//w3c//dtd html 4.0 final//en">'
> / @01 '<html>'
> / @04 '<head>'
> / @07 "<title>My Macro </title>"
> / @04 '</head>'
> / @04 '<body>'
> / @07 '<pre>'
> ;
> Input ;
> _infile_=tranwrd(_infile_,'&','&');
> _infile_=tranwrd(_infile_,'<','<');
> _infile_=tranwrd(_infile_,'>','>');
> Put _infile_ ;
> If eof then put
> @07 '</pre>'
> / @04 '</body>'
> / @01 '</html>'
> ;
> Run ;
>
> Should that suffice as a home-made version of protectspecialchars? Or are
> there other chars I need to worry about?
>
> Thanks again,
> --Quentin
|