<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic No function HTMLENCODE() in Proc DS2? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/No-function-HTMLENCODE-in-Proc-DS2/m-p/968968#M376700</link>
    <description>&lt;P&gt;Base SAS has the HTMLENCODE() function, and there is not the same available to Proc DS2, nor Proc FCMP.&lt;/P&gt;
&lt;P&gt;The HTTP package does not seem to have anything to do the same.&lt;/P&gt;
&lt;P&gt;Is there any way to trick DS2 into using HTMLENCODE?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;The node name needs to be html-encoded in certain situations&lt;/P&gt;
&lt;PRE&gt;%let MAX_LEN_PART = 200 ;
proc ds2 ;
  package sasuser.Node / overwrite=yes ;
    declare varchar(512) name newname ;
    declare package sasuser.Node parent ;
    declare package sasuser.Node children ;
    declare package sasuser.Node next ;
  
    method init() ;
      alias_counter = 0 ;
    end ;
  
    method Node(varchar(512) name, package sasuser.Node parent, in_out double alias_count) ;
      this.name = name ;
      this.newname = name ;
      this.parent = parent ;
      if verify(name,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 !#$%&amp;amp;''()+,-.;=@[]^`{}~/') then do ;
        this.newname = htmlencode(name, '7bit') ;
        put newname= ;
      end ;
      if length(this.newname) &amp;gt; &amp;amp;MAX_LEN_PART then do ;
        alias_count + 1 ;
        this.newname = '_migrate_' || put(alias_counter,z4.) ;
        put newname= ;
      end ;
    end ;

    method Node(varchar(512) name) ;
      this.name = name ;
    end ;

    method get_path() returns varchar(4096) ;
      if null(parent)
        then return name ; 
        else return parent.get_path() || '/' || name ;
    end ;
  endpackage /* Node */;
  
  data _null_;
  enddata;
  run ;
quit ;&lt;/PRE&gt;
&lt;P&gt;But the log shows:&lt;/P&gt;
&lt;PRE&gt;ERROR: Compilation error.
ERROR: Unknown function htmlencode.
NOTE: PROC DS2 has set option NOEXEC and will continue to prepare statements.&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Jun 2025 11:22:55 GMT</pubDate>
    <dc:creator>RichardAD</dc:creator>
    <dc:date>2025-06-13T11:22:55Z</dc:date>
    <item>
      <title>No function HTMLENCODE() in Proc DS2?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/No-function-HTMLENCODE-in-Proc-DS2/m-p/968968#M376700</link>
      <description>&lt;P&gt;Base SAS has the HTMLENCODE() function, and there is not the same available to Proc DS2, nor Proc FCMP.&lt;/P&gt;
&lt;P&gt;The HTTP package does not seem to have anything to do the same.&lt;/P&gt;
&lt;P&gt;Is there any way to trick DS2 into using HTMLENCODE?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;The node name needs to be html-encoded in certain situations&lt;/P&gt;
&lt;PRE&gt;%let MAX_LEN_PART = 200 ;
proc ds2 ;
  package sasuser.Node / overwrite=yes ;
    declare varchar(512) name newname ;
    declare package sasuser.Node parent ;
    declare package sasuser.Node children ;
    declare package sasuser.Node next ;
  
    method init() ;
      alias_counter = 0 ;
    end ;
  
    method Node(varchar(512) name, package sasuser.Node parent, in_out double alias_count) ;
      this.name = name ;
      this.newname = name ;
      this.parent = parent ;
      if verify(name,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789 !#$%&amp;amp;''()+,-.;=@[]^`{}~/') then do ;
        this.newname = htmlencode(name, '7bit') ;
        put newname= ;
      end ;
      if length(this.newname) &amp;gt; &amp;amp;MAX_LEN_PART then do ;
        alias_count + 1 ;
        this.newname = '_migrate_' || put(alias_counter,z4.) ;
        put newname= ;
      end ;
    end ;

    method Node(varchar(512) name) ;
      this.name = name ;
    end ;

    method get_path() returns varchar(4096) ;
      if null(parent)
        then return name ; 
        else return parent.get_path() || '/' || name ;
    end ;
  endpackage /* Node */;
  
  data _null_;
  enddata;
  run ;
quit ;&lt;/PRE&gt;
&lt;P&gt;But the log shows:&lt;/P&gt;
&lt;PRE&gt;ERROR: Compilation error.
ERROR: Unknown function htmlencode.
NOTE: PROC DS2 has set option NOEXEC and will continue to prepare statements.&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jun 2025 11:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/No-function-HTMLENCODE-in-Proc-DS2/m-p/968968#M376700</guid>
      <dc:creator>RichardAD</dc:creator>
      <dc:date>2025-06-13T11:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: No function HTMLENCODE() in Proc DS2?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/No-function-HTMLENCODE-in-Proc-DS2/m-p/969072#M376721</link>
      <description>&lt;P&gt;The list of DS2 functions is &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/ds2ref/n16ozh3c6mx1uwn1feg8exu9vwpz.htm" target="_self"&gt;here&lt;/A&gt;. You can &lt;A href="https://communities.sas.com/t5/SAS-Product-Suggestions/idb-p/product-suggestions" target="_self"&gt;add a suggestion&lt;/A&gt; if you want more functions supported.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jun 2025 23:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/No-function-HTMLENCODE-in-Proc-DS2/m-p/969072#M376721</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2025-06-15T23:53:54Z</dc:date>
    </item>
  </channel>
</rss>

