<?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 extracting part of a string in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249886#M9526</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose I have a data set with datalines in the following manner:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the first site is &lt;A href="http://www.abc.com" target="_blank"&gt;www.abc.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.123.com" target="_blank"&gt;www.123.com&lt;/A&gt; is the second website.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to figure out how to extract the websites, that is, the part of the string which is between (and including) "www." and ".com"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Sat, 13 Feb 2016 19:23:49 GMT</pubDate>
    <dc:creator>ilikesas</dc:creator>
    <dc:date>2016-02-13T19:23:49Z</dc:date>
    <item>
      <title>extracting part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249886#M9526</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose I have a data set with datalines in the following manner:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the first site is &lt;A href="http://www.abc.com" target="_blank"&gt;www.abc.com&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.123.com" target="_blank"&gt;www.123.com&lt;/A&gt; is the second website.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to figure out how to extract the websites, that is, the part of the string which is between (and including) "www." and ".com"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 13 Feb 2016 19:23:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249886#M9526</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-02-13T19:23:49Z</dc:date>
    </item>
    <item>
      <title>Re: extracting part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249901#M9527</link>
      <description>&lt;P&gt;one way&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input x $37.;
cards;
the first site is www.abc.com
www.187878723.com is the second website.
www.computer.com is the second website.
;
run;

data want ;
set have;
www=index(x, "www.");
com=index(substr(x,www+4), ".com");
if www and com then website=substr(x,www,com+7);
drop www com;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Feb 2016 00:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249901#M9527</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-14T00:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: extracting part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249909#M9528</link>
      <description>&lt;P&gt;updated to handle more cases&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2016 00:19:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249909#M9528</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-14T00:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: extracting part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249912#M9529</link>
      <description>&lt;P&gt;Hi Mohamed,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you for answering my question, everything works nicely!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just on the sidenote, if I add a dataline " a pseudo site www. name .com", the code will still select "www. name .com" into want, but it isn't a real website becasue of the space after www. and before .com&lt;/P&gt;
&lt;P&gt;So is there a way to avoide it by specifying that right after www. and right before .com there should be a character?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2016 00:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249912#M9529</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-02-14T00:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: extracting part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249913#M9530</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if www and com then website=compress(substr(x,www,com+7));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Feb 2016 00:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249913#M9530</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-14T00:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: extracting part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249915#M9531</link>
      <description>&lt;P&gt;Do you still want to extreact it correctly? .... or to consider it wrong and neglect it?&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2016 00:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249915#M9531</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-14T00:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: extracting part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249921#M9532</link>
      <description>&lt;P&gt;I ran the code with your new input and understand that it corrects it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please also show me the option to neglect such a case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thnak you!&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2016 01:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249921#M9532</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-02-14T01:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: extracting part of a string</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249953#M9533</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
set have;
www=index(x, "www.");
com=index(substr(x,www+4), ".com");
website=substr(x,www,com+7);
if www and com;
if index(trim(website),' ')&amp;gt; 0 then website="";
drop www com;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 14 Feb 2016 12:20:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/extracting-part-of-a-string/m-p/249953#M9533</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-14T12:20:21Z</dc:date>
    </item>
  </channel>
</rss>

