<?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: How to convert xml to url in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-xml-to-url/m-p/884657#M349502</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288727"&gt;@shlomiohana&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p19ckwqexa3ir8n19hbvcz73lhmj.htm" target="_blank" rel="noopener"&gt;URLENCODE function&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input xml $80.;
cards;
&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;SMF_REQUEST_PARAMS&amp;gt;
&amp;lt;customerIdType&amp;gt;1&amp;lt;/customerIdType&amp;gt;
&amp;lt;customerId&amp;gt;312755468&amp;lt;/customerId&amp;gt;
&amp;lt;/SMF_REQUEST_PARAMS&amp;gt;
;

data want;
set have end=last;
length url $1000;
url=catt(url,urlencode(trim(xml)));
if last;
retain url;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really need the double linefeed characters (hex 0A) representing the line breaks, insert&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not last then url=catt(url,'%0A%0A');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;before the subsetting IF statement &lt;FONT face="courier new,courier"&gt;if last&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your sample output also shows some blanks (hex 20) after line 2 and 3. To reproduce this in this particular example, you could insert a second IF statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if _n_ in (2, 3) then url=catt(url,'%20%20%20');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but I don't think this is useful.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jul 2023 12:00:39 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2023-07-13T12:00:39Z</dc:date>
    <item>
      <title>How to convert xml to url</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-xml-to-url/m-p/884629#M349496</link>
      <description>Hi,&lt;BR /&gt;How can i convert XML to URL with sas?&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;Xml:&lt;BR /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;BR /&gt;&amp;lt;SMF_REQUEST_PARAMS&amp;gt;&lt;BR /&gt;&amp;lt;customerIdType&amp;gt;1&amp;lt;/customerIdType&amp;gt;&lt;BR /&gt;&amp;lt;customerId&amp;gt;312755468&amp;lt;/customerId&amp;gt;&lt;BR /&gt;&amp;lt;/SMF_REQUEST_PARAMS&amp;gt;&lt;BR /&gt;&lt;BR /&gt;URL CONVERT:&lt;BR /&gt;%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%0A%3CSMF_REQUEST_PARAMS%3E%0A%0A%20%20%20%3CcustomerIdType%3E1%3C%2FcustomerIdType%3E%0A%0A%20%20%20%3CcustomerId%3E312755468%3C%2FcustomerId%3E%0A%0A%3C%2FSMF_REQUEST_PARAMS%3E&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Thu, 13 Jul 2023 09:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-xml-to-url/m-p/884629#M349496</guid>
      <dc:creator>shlomiohana</dc:creator>
      <dc:date>2023-07-13T09:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert xml to url</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-xml-to-url/m-p/884657#M349502</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288727"&gt;@shlomiohana&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p19ckwqexa3ir8n19hbvcz73lhmj.htm" target="_blank" rel="noopener"&gt;URLENCODE function&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input xml $80.;
cards;
&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;SMF_REQUEST_PARAMS&amp;gt;
&amp;lt;customerIdType&amp;gt;1&amp;lt;/customerIdType&amp;gt;
&amp;lt;customerId&amp;gt;312755468&amp;lt;/customerId&amp;gt;
&amp;lt;/SMF_REQUEST_PARAMS&amp;gt;
;

data want;
set have end=last;
length url $1000;
url=catt(url,urlencode(trim(xml)));
if last;
retain url;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really need the double linefeed characters (hex 0A) representing the line breaks, insert&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not last then url=catt(url,'%0A%0A');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;before the subsetting IF statement &lt;FONT face="courier new,courier"&gt;if last&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your sample output also shows some blanks (hex 20) after line 2 and 3. To reproduce this in this particular example, you could insert a second IF statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if _n_ in (2, 3) then url=catt(url,'%20%20%20');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but I don't think this is useful.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 12:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-xml-to-url/m-p/884657#M349502</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-07-13T12:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert xml to url</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-xml-to-url/m-p/884660#M349503</link>
      <description>&lt;PRE&gt;data have;
have='&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;SMF_REQUEST_PARAMS&amp;gt;
&amp;lt;customerIdType&amp;gt;1&amp;lt;/customerIdType&amp;gt;
&amp;lt;customerId&amp;gt;312755468&amp;lt;/customerId&amp;gt;
&amp;lt;/SMF_REQUEST_PARAMS&amp;gt;';
want=urlencode(have);
run;
&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1689250035854.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85757i1CEEAC40CFDC3565/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1689250035854.png" alt="Ksharp_0-1689250035854.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 12:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-xml-to-url/m-p/884660#M349503</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-07-13T12:07:01Z</dc:date>
    </item>
  </channel>
</rss>

