<?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 Re: PROC ODSTEXT producing unexpected results with %SYSFUNC(URLENCODE(...)) in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/526366#M22165</link>
    <description>&lt;P&gt;Thanks for taking a look,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;.&amp;nbsp; I just opened a ticket with Tech Support and will report back when I have more info.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Jan 2019 13:57:11 GMT</pubDate>
    <dc:creator>JRoman</dc:creator>
    <dc:date>2019-01-11T13:57:11Z</dc:date>
    <item>
      <title>PROC ODSTEXT producing unexpected results with %SYSFUNC(URLENCODE(...))</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/526242#M22160</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When using PROC ODSTEXT's P statement with strings containing %SYSFUNC(URLENCODE(...)), I'm getting unexpected results in certain cases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In particular, if the string being encoded has one or more digits and those digits are surrounded on both sides by a space, the digits and one of the spaces do not appear in the resulting text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data foo;
  s  = urlencode('abc 123 xyz.txt');
  s2 = "%sysfunc(urlencode(abc 123 xyz.txt))";
run;

proc odstext data=foo;
  * First two work, third one loses the 123 and a space. ;
  p s;
  p s2;
  p "%sysfunc(urlencode(abc 123 xyz.txt))";

  * First one works, second one loses the 1 and a space. ;
  p "%sysfunc(urlencode(this works just fine))";
  p "%sysfunc(urlencode(this 1 has an issue))";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="proc_odstext_with_sysfunc_and_urlencode.PNG" style="width: 486px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26184iC8927FB2517A3288/image-size/large?v=v2&amp;amp;px=999" role="button" title="proc_odstext_with_sysfunc_and_urlencode.PNG" alt="proc_odstext_with_sysfunc_and_urlencode.PNG" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this the expected behavior?&amp;nbsp; As the above example illustrates, it is possible to work around this issue by storing the encoded text in a data set first, but it does not seem that such an approach should be necessary, should it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This issue (or one very similar) appears to have also been encountered by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt; in &lt;A href="https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-HTML-Text-url-encoding-problem/m-p/259435/highlight/true#M15476" target="_self"&gt;this post&lt;/A&gt;.&amp;nbsp; In that case, the resolution was to use the URL style.&amp;nbsp; In my current case, that would not be applicable because the content I need to output is not being displayed as a clickable hyperlink to the user; rather, I am sending the content as a response from a stored process, and the client browser will be accessing the returned URL directly, without any interaction from the user.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm on SAS 9.4M5.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jake&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 00:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/526242#M22160</guid>
      <dc:creator>JRoman</dc:creator>
      <dc:date>2019-01-11T00:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: PROC ODSTEXT producing unexpected results with %SYSFUNC(URLENCODE(...))</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/526255#M22164</link>
      <description>&lt;P&gt;This feels like an undocumented feature worth raising with SAS TechSupport. If you do so please let us know the outcome.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 01:42:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/526255#M22164</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-01-11T01:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC ODSTEXT producing unexpected results with %SYSFUNC(URLENCODE(...))</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/526366#M22165</link>
      <description>&lt;P&gt;Thanks for taking a look,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;.&amp;nbsp; I just opened a ticket with Tech Support and will report back when I have more info.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 13:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/526366#M22165</guid>
      <dc:creator>JRoman</dc:creator>
      <dc:date>2019-01-11T13:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: PROC ODSTEXT producing unexpected results with %SYSFUNC(URLENCODE(...))</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/526383#M22167</link>
      <description>&lt;P&gt;Agree this is a good one for tech support.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's interesting proc ODSTEXT works like you want when the value is read from a data set, but not when it's a literal value.&amp;nbsp; Could be a bug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can see it with just:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data foo;
  s  = 'this%201%20works';
run;

proc odstext data=foo;
  p s ;
  p 'this%201%20does%20not%20work';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Returns&amp;nbsp; (9.4M4):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;this%201%20works

this%20does%20not%20work
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like an alpha character or blank after the %201 and before then next % makes it work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc odstext data=foo;
  p 'this%201.%20does%not%20work';
  p 'this%201.123456789%20does%20not%20work';
  p 'this%201q%20does%20work';
  p 'this%201 %20does%20work';
  p 'this%201.1234q56789%20does%20work';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Returns:&lt;/P&gt;
&lt;PRE&gt;this%20does%not%20work

this%20does%20not%20work

this%201q%20does%20work

this%201 %20does%20work

this%201.1234q56789%20does%20work
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please do let us know what tech support says.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 15:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/526383#M22167</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2019-01-11T15:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: PROC ODSTEXT producing unexpected results with %SYSFUNC(URLENCODE(...))</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/529518#M22248</link>
      <description>&lt;P&gt;Thanks for those concise examples, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879"&gt;@Quentin&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tech Support confirmed there is indeed a defect leading to PROC ODSTEXT not properly handling certain string literals that contain URL-encoded text, and that the issue will hopefully be addressed in a future release.&amp;nbsp; (No version details at this time.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the meantime, three workarounds for the issue are:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;1.) double the percent signs in the string literal,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc odstext;
  p 'A%%201%%20B';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.) pass the non-encoded string literal to the URLENCODE function in the P statement, rather than calling %SYSFUNC(URLENCODE(...)) within the string literal,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc odstext;
  p urlencode('A 1 B');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3.) or store the encoded string in a data set variable and reference that variable in the P statement, rather than using a string literal.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data foo;
  s = urlencode('A 1 B');
run;
proc odstext data=foo;
  p s;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All three of the above examples produce the same desired result:&lt;/P&gt;&lt;PRE&gt;A%201%20B&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2019 20:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-ODSTEXT-producing-unexpected-results-with-SYSFUNC-URLENCODE/m-p/529518#M22248</guid>
      <dc:creator>JRoman</dc:creator>
      <dc:date>2019-01-23T20:20:05Z</dc:date>
    </item>
  </channel>
</rss>

