<?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 find the first position of a string? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-position-of-a-string/m-p/772485#M245287</link>
    <description>Have you considered the SCAN function instead?&lt;BR /&gt;&lt;BR /&gt;URL_FULL = scan(clause3, 2, ",");&lt;BR /&gt;URL = scan(url_full, 2, ":");&lt;BR /&gt;&lt;BR /&gt;Or try URL = scan(clause3, 4, ",:");&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 06 Oct 2021 16:48:45 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-10-06T16:48:45Z</dc:date>
    <item>
      <title>How to find the first position of a string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-position-of-a-string/m-p/772483#M245285</link>
      <description>&lt;P&gt;Hi, I'm trying to find the position of where the second "," is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, this is my data and code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test2;&lt;BR /&gt;clause3="[Type:File, URL :websitedomainname&amp;nbsp;, Version :21 , Status :done , Date :01JUN2021 Notes :none" ;&lt;/P&gt;&lt;P&gt;n2=index(upcase(clause3),'URL :');&lt;BR /&gt;n3=index(clause3,', Version');&lt;BR /&gt;if n2&amp;gt;0 then do;&lt;BR /&gt;URL=substr(clause3,n2, n3);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to take whatever is after URL: and create it as it's own variable. However, I want it to only take "websitedomainname "...so how do i find the position of the comma after .com so i can apply that position in my substr function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, this is what i'm getting&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;n2&amp;nbsp; &amp;nbsp; &amp;nbsp; n3&amp;nbsp; &amp;nbsp; &amp;nbsp;URL&lt;/P&gt;&lt;P&gt;13&amp;nbsp; &amp;nbsp; &amp;nbsp; 35&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;URL :websitedomainname&amp;nbsp; , Version :21&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What i would like is&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;n2&amp;nbsp; &amp;nbsp; &amp;nbsp; n3&amp;nbsp; &amp;nbsp; &amp;nbsp;URL&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; websitedomainname&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your help is greatly appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 16:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-position-of-a-string/m-p/772483#M245285</guid>
      <dc:creator>Dregerator</dc:creator>
      <dc:date>2021-10-06T16:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the first position of a string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-position-of-a-string/m-p/772485#M245287</link>
      <description>Have you considered the SCAN function instead?&lt;BR /&gt;&lt;BR /&gt;URL_FULL = scan(clause3, 2, ",");&lt;BR /&gt;URL = scan(url_full, 2, ":");&lt;BR /&gt;&lt;BR /&gt;Or try URL = scan(clause3, 4, ",:");&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 06 Oct 2021 16:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-position-of-a-string/m-p/772485#M245287</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-06T16:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the first position of a string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-position-of-a-string/m-p/772486#M245288</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/301047"&gt;@Dregerator&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi, I'm trying to find the position of where the second "," is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, this is my data and code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test2;&lt;BR /&gt;clause3="[Type:File, URL :websitedomainname&amp;nbsp;, Version :21 , Status :done , Date :01JUN2021 Notes :none" ;&lt;/P&gt;
&lt;P&gt;n2=index(upcase(clause3),'URL :');&lt;BR /&gt;n3=index(clause3,', Version');&lt;BR /&gt;if n2&amp;gt;0 then do;&lt;BR /&gt;URL=substr(clause3,n2, n3);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to take whatever is after URL: and create it as it's own variable. However, I want it to only take "websitedomainname "...so how do i find the position of the comma after .com so i can apply that position in my substr function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently, this is what i'm getting&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;n2&amp;nbsp; &amp;nbsp; &amp;nbsp; n3&amp;nbsp; &amp;nbsp; &amp;nbsp;URL&lt;/P&gt;
&lt;P&gt;13&amp;nbsp; &amp;nbsp; &amp;nbsp; 35&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;URL :websitedomainname&amp;nbsp; , Version :21&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What i would like is&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;n2&amp;nbsp; &amp;nbsp; &amp;nbsp; n3&amp;nbsp; &amp;nbsp; &amp;nbsp;URL&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; websitedomainname&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your help is greatly appreciated.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your question asks " how do i find the position of the comma after .com" which is different than "second comma". Plus, your example does not include ".com".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Find functions have an optional fourth parameter which is start position. So you could determine the position of the string ".com" and use that as the start position to find a comma.&lt;/P&gt;
&lt;P&gt;This finds the first comma after the first time ".com" appears:&lt;/P&gt;
&lt;PRE&gt;data example;
clause3="some text, other text, abc.com , text following .com" ;
commapostcom = findc(clause3,',','i',find(clause3,'.com','i'));
run;
&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Oct 2021 16:51:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-first-position-of-a-string/m-p/772486#M245288</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-06T16:51:14Z</dc:date>
    </item>
  </channel>
</rss>

