<?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 All Position of Same Character In a String in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261299#M18207</link>
    <description>&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;data want (drop=i);
  length result $200;
  val="BAAABAABAB";
  do i=1 to lengthn(val);
    if char(val,i)="B" then result=catx(",",result,strip(put(i,best.)));
  end;
run;
&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Apr 2016 08:02:40 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-04-05T08:02:40Z</dc:date>
    <item>
      <title>How to Find All Position of Same Character In a String</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261293#M18205</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a function that determines the position of the same character in a string. For example, I want to know the position of the characters 'B' in a string BAAABAABAB. I am expecting the results: 1,5,8,and 10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 07:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261293#M18205</guid>
      <dc:creator>chedrbalingit</dc:creator>
      <dc:date>2016-04-05T07:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find All Position of Same Character In a String</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261298#M18206</link>
      <description>&lt;P&gt;The FIND() function is perfectly suited for this because it allows for a start position inside the searched string:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	string='ABAAABAABAB';
	pos = 0;

	do until (pos = 0);
		pos = find (string, 'B', pos+1);
		if pos&amp;gt;0 then put pos=;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 08:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261298#M18206</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-04-05T08:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find All Position of Same Character In a String</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261299#M18207</link>
      <description>&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;data want (drop=i);
  length result $200;
  val="BAAABAABAB";
  do i=1 to lengthn(val);
    if char(val,i)="B" then result=catx(",",result,strip(put(i,best.)));
  end;
run;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Apr 2016 08:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261299#M18207</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-05T08:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find All Position of Same Character In a String</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261310#M18209</link>
      <description>&lt;PRE&gt;
data _null_;
x='BAAABAABAB';
do i=1 to length(x);
 if char(x,i)='B' then putlog 'Position:' i;
end;
run;


&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Apr 2016 09:25:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261310#M18209</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-05T09:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find All Position of Same Character In a String</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261313#M18210</link>
      <description>&lt;P&gt;I think there is room for interpretation what exactly you would like to do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Let Max_Len=20; *!!;

Data A;
  Attrib Txt Length=$&amp;amp;Max_Len.;
  Txt='AABBBBAAAAAABBABAB'; Output;
  Txt='GDFSCCCDD'; Output;
  Txt='DFDCZ'; Output;
Run;

Data _NULL_;
  Length Letters $300.;
  Letters='Capital_A';
  Do i=2 To 26; 
    Letters=Catt(Letters,' Capital_',Byte(i+64));
  End;
  Call SymputX('Letters',Letters);
Run;

Data Want;
  Set A;
  Array C_[*] $%Eval(&amp;amp;Max_Len*4) &amp;amp;Letters. ;
  Do i=1 To &amp;amp;Max_Len.;
    dummy=Substr(Txt,i,1);
	ascii=Rank(dummy);
    If ascii ne 32 Then Do;
      If not Missing (C_[ascii-64]) Then C_[ascii-64]=Catt(C_[ascii-64],', ',Put(i,Best4.));
	  Else C_[ascii-64]=Trim(Put(i,Best4.));
	End;
  End;
  Do i=1 To Dim(C_);
    Character=VName(C_[i]);
	Positions=C_[i];
	If not Missing (Positions) Then Output;
  End;
  Drop &amp;amp;Letters. dummy ascii i;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Apr 2016 09:34:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261313#M18210</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2016-04-05T09:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to Find All Position of Same Character In a String</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261364#M18213</link>
      <description>&lt;P&gt;Nice piece of code, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13094"&gt;@user24feb﻿&lt;/a&gt;. Would you like to share what interpretation your solution is based upon?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My native language has no direct translation of "convoluted". I miss that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2016 13:03:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-Find-All-Position-of-Same-Character-In-a-String/m-p/261364#M18213</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-04-05T13:03:09Z</dc:date>
    </item>
  </channel>
</rss>

