LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2004, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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 &note %then %put The sum is &sum; > %if a<b %then %do; > %end; > %mend me; > > The browser interprets &note as being an html symbol &not followed by the > letter 'e', and "&sum;" 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_,'&','&amp;'); > _infile_=tranwrd(_infile_,'<','&lt;'); > _infile_=tranwrd(_infile_,'>','&gt;'); > 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


Back to: Top of message | Previous page | Main SAS-L page