<?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 can I translate html embedded in strings? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204504#M50962</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bruno,&lt;/P&gt;&lt;P&gt;I could not find a proc that handles html gracefully. But the regular expressions were not as bad as I thought.&lt;/P&gt;&lt;P&gt;You get full credit for your RegEx! it is way better than mine! And it does 99% of the job. I still get weird strings like \n\n but they are easy to remove with some SAS code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Apr 2015 15:58:49 GMT</pubDate>
    <dc:creator>M_Maldonado</dc:creator>
    <dc:date>2015-04-27T15:58:49Z</dc:date>
    <item>
      <title>how can I translate html embedded in strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204500#M50958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All,&lt;/P&gt;&lt;P&gt;I have a data set that with embedded htlm in strings. Can I use some SAS function to translate that html?&lt;/P&gt;&lt;P&gt;Data set example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;data posts;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; length id $5 username $10 post $250;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; infile datalines delimiter=','; &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; input id $ username $ post $;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; datalines;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px; padding-left: 30px;"&gt;338,"jessykate",&amp;lt;a class=\"mention\" href=\"/users/tim\"&amp;gt;@tim&amp;lt;\/a&amp;gt; AHA!! thank you! i will try that :D.&amp;nbsp; &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;223,"chris",Hi All &amp;lt;\/p&amp;gt;\n\n&amp;lt;p&amp;gt;Quick update on discourse - File uploads now work - Upload away!&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;SPAN&gt;1017,"ralfe",Hi &amp;lt;\/p&amp;gt;\n\n&amp;lt;p&amp;gt;I quite like &amp;lt;a class=\"mention\" href=\"/users/ahnjune\"&amp;gt;@ahnjune&amp;lt;\/a&amp;gt; 's suggestion. If you go to &amp;lt;a href=\"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://p2pu.org"&gt;https://p2pu.org&lt;/A&gt;&lt;SPAN&gt;\"&amp;gt;&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://p2pu.org"&gt;https://p2pu.org&lt;/A&gt;&lt;SPAN&gt;&amp;lt;\/a&amp;gt;&amp;nbsp; then click on the drop-down arrow to the right of your profile&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Concrete example, after applying some SAS magic, I would like the string in the first observation "&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&amp;lt;a class=\"mention\" href=\"/users/tim\"&amp;gt;@tim&amp;lt;\/a&amp;gt;&lt;/SPAN&gt;" to get translated to "@tim".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I read about libname OLEDB here (&lt;A __default_attr="126937" __jive_macro_name="message" class="jive_macro jive_macro_message" href="https://communities.sas.com/"&gt;&lt;/A&gt;) from &lt;A __default_attr="645292" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; and &lt;A __default_attr="149594" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; but I did not get very far.&lt;/P&gt;&lt;P&gt;Can I borrow some code to quick fidx my data set?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 14:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204500#M50958</guid>
      <dc:creator>M_Maldonado</dc:creator>
      <dc:date>2015-04-27T14:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: how can I translate html embedded in strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204501#M50959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; So you explained what you want for the first row, can you explain what you would expect to get on the 2nd row and the 3rd row, too??? I do not believe you really need OLEDB, If all you are doing is extracting the string BEFORE the brackets, then you can probably use the SCAN or PRX functions.&lt;/P&gt;&lt;P style="padding-left: 30px; font-size: 13.33px;"&gt;338,"jessykate",&amp;lt;a class=\"mention\" href=\"/users/tim\&lt;SPAN style="font-size: 14pt;"&gt;&lt;STRONG&gt;"&amp;gt;&lt;SPAN style="color: #ff00ff;"&gt;@tim&lt;/SPAN&gt;&amp;lt;&lt;/STRONG&gt;&lt;STRONG&gt;\/a&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt; AHA!! thank you! i will try that :D. &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;223,"chris",Hi All &amp;lt;\/p&amp;gt;\n\n&amp;lt;p&amp;gt;Quick update on discourse - File uploads now work - Upload away!&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;1017,"ralfe",Hi &amp;lt;\/p&amp;gt;\n\n&amp;lt;p&amp;gt;I quite like &amp;lt;a class=\"mention\" href=\"/users/ahnjune\&lt;STRONG style="font-size: 14pt;"&gt;"&amp;gt;&lt;SPAN style="color: #ff00ff;"&gt;@ahnjune&lt;/SPAN&gt;&amp;lt;\/a&amp;gt;&lt;/STRONG&gt; 's suggestion. If you go to &amp;lt;a href=\"&lt;A class="jive-link-external-small" href="https://p2pu.org/"&gt;https://p2pu.org&lt;/A&gt;\"&amp;gt;&lt;A class="jive-link-external-small" href="https://p2pu.org/"&gt;https://p2pu.org&lt;/A&gt;&amp;lt;\/a&amp;gt;&amp;nbsp; then click on the drop-down arrow to the right of your profile&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Would you want &lt;STRONG&gt;@ahnjune&lt;/STRONG&gt; for the 3rd row??? but what about the 2nd row of data????&lt;BR /&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204501#M50959</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2015-04-27T15:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: how can I translate html embedded in strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204502#M50960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cynthia,&lt;/P&gt;&lt;P&gt;Ideally I want to avoid writing a regular expression or a string code for each case.&lt;/P&gt;&lt;P&gt;I was wondering if we have some way to translate html text directly. Otherwise I need to come up with all these rules myself. This data set is quite large...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Examples of rules that I would need to come up with, but are too many to even try :smileyplain:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;String&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Translates to&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&amp;lt;a class=\"mention\" href=\"/users/FOO\"&amp;gt;@FOO&amp;lt;\/a&amp;gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;@FOO&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&amp;lt;\/p&amp;gt;\n\n&amp;lt;p&amp;gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;" "&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;lt;a href=\"&lt;A class="jive-link-external-small" href="https://FOO.ORG\&amp;quot;&amp;gt;https//p2pu.org&amp;lt;\/a"&gt;https://FOO.ORG\"&amp;gt;&lt;/A&gt;&lt;A class="jive-link-external-small" href="https://FOO.org/"&gt;https://FOO.org&lt;/A&gt;&lt;A class="jive-link-external-small" href="https://FOO.ORG\&amp;quot;&amp;gt;https//p2pu.org&amp;lt;\/a"&gt;&amp;lt;\/a&lt;/A&gt;&amp;gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;FOO.org&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:10:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204502#M50960</guid>
      <dc:creator>M_Maldonado</dc:creator>
      <dc:date>2015-04-27T15:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: how can I translate html embedded in strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204503#M50961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Miguel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can make use of Perl Regular Expression functions to do what you want. For the case you are interested you can make use of the &lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/67398/HTML/default/viewer.htm#n0r8h2fa8djqf1n1cnenrvm573br.htm"&gt;PRXCHANGE&lt;/A&gt; function See sample below. The HTML tags are placed by "*". As I am not the Regex expert, I search for what I want to do, and then adapt the Regex to the appropriate SAS PRX... function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; posts;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; id $&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;5&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; username $&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;10&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; post $&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;250&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;datalines&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;delimiter&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;','&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; id $ username $ post $;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; post2 = prxchange(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"s/&amp;lt;[^&amp;gt;]*&amp;gt;/*/ "&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, -&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, post);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;datalines4&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;338,"jessykate",&amp;lt;a class=\"mention\" href=\"/users/tim\"&amp;gt;@tim&amp;lt;\/a&amp;gt; AHA!! thank you! i will try that :D. &lt;BR /&gt;223,"chris",Hi All &amp;lt;\/p&amp;gt;\n\n&amp;lt;p&amp;gt;Quick update on discourse - File uploads now work - Upload away!&lt;BR /&gt;&lt;SPAN&gt;1017,"ralfe",Hi &amp;lt;\/p&amp;gt;\n\n&amp;lt;p&amp;gt;I quite like &amp;lt;a class=\"mention\" href=\"/users/ahnjune\"&amp;gt;@ahnjune&amp;lt;\/a&amp;gt; 's suggestion. If you go to &amp;lt;a href=\"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://p2pu.org"&gt;https://p2pu.org&lt;/A&gt;&lt;SPAN&gt;\"&amp;gt;&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://p2pu.org"&gt;https://p2pu.org&lt;/A&gt;&lt;SPAN&gt;&amp;lt;\/a&amp;gt;&amp;nbsp; then click on the drop-down arrow to the right of your profile&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204503#M50961</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2015-04-27T15:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: how can I translate html embedded in strings?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204504#M50962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bruno,&lt;/P&gt;&lt;P&gt;I could not find a proc that handles html gracefully. But the regular expressions were not as bad as I thought.&lt;/P&gt;&lt;P&gt;You get full credit for your RegEx! it is way better than mine! And it does 99% of the job. I still get weird strings like \n\n but they are easy to remove with some SAS code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-can-I-translate-html-embedded-in-strings/m-p/204504#M50962</guid>
      <dc:creator>M_Maldonado</dc:creator>
      <dc:date>2015-04-27T15:58:49Z</dc:date>
    </item>
  </channel>
</rss>

