<?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: Scan multiple Delimiter in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806327#M317662</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/422125"&gt;@Deb4&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just determine the position of that last delimiter (&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1mdh2gvd5potjn14jipysvzn4o7.htm" target="_blank" rel="noopener"&gt;FINDC function&lt;/A&gt;) and then extract the two parts of the string using the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0n08xougp40i5n1xw7njpcy0a2b.htm" target="_blank" rel="noopener"&gt;SUBSTR function&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
addr='West of arrell street 1/2/SAN PEDRO CA 90731';
run;

data want(drop=p);
set have;
p=findc(addr,'/','b');
addr1=substr(addr, 1, p-1);
addr2=left(substr(addr, p+1));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I used the LEFT function to ensure that ADDR2 does not contain leading blanks. Feel free to define shorter lengths (than the default, which is the defined length of ADDR) for ADDR1 and ADDR2 with a LENGTH statement.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Apr 2022 15:53:22 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2022-04-06T15:53:22Z</dc:date>
    <item>
      <title>Scan multiple Delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806307#M317649</link>
      <description>So I am trying to delimit(/) an address variable using Scan function. But I only need to use the last delimiter and not the initial delimiters which are string.&lt;BR /&gt;&lt;BR /&gt;For Eg: West of arrell street 1/2/SAN PEDRO CA 90731.&lt;BR /&gt;I want 'SAN PEDRO CA 9073' in a different column while 'West of arrell street 1/2' in another. But my code is considering both the (/) as delimiters.&lt;BR /&gt;How to write a scan function in such a way that it only considers the final (/) or initial(if reversed) as delimiters and ignore the rest of them?</description>
      <pubDate>Wed, 06 Apr 2022 14:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806307#M317649</guid>
      <dc:creator>Deb4</dc:creator>
      <dc:date>2022-04-06T14:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Scan multiple Delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806324#M317660</link>
      <description>&lt;P&gt;This is where using a negative value for the position parameter of the SCAN function is just the right tool to get the last component (because a negative number starts from the last position and works towards the first).&amp;nbsp; Then, to get the first component, apply TRANWRD to the original text to "translate" the last component to a blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  original_text="West of arrell street 1/2/SAN PEDRO CA 90731";
  last_component=scan(original_text,-1,'/');
  first_component=tranwrd(original_text,cats('/',last_component),'');
  put (_all_) (=);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only flaw in this would be if the string composing the last_component appears more than once, which would remove the first instance.&amp;nbsp; &amp;nbsp;You can avoid this by locating the text position of last character that precedes the "/" that demarks the last component (&lt;STRIKE&gt;actually one character to the left&lt;/STRIKE&gt;), then just copy a substring of the original text through that position:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  original_text="West of arrell street 1/2/SAN PEDRO CA 90731";
  last_component=scan(original_text,-1,'/');
  first_component=substr(original_text,1, length(original_text)-length(last_component)-1);
  put (_all_) (=);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 17:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806324#M317660</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-04-06T17:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: Scan multiple Delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806327#M317662</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/422125"&gt;@Deb4&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just determine the position of that last delimiter (&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1mdh2gvd5potjn14jipysvzn4o7.htm" target="_blank" rel="noopener"&gt;FINDC function&lt;/A&gt;) and then extract the two parts of the string using the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0n08xougp40i5n1xw7njpcy0a2b.htm" target="_blank" rel="noopener"&gt;SUBSTR function&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
addr='West of arrell street 1/2/SAN PEDRO CA 90731';
run;

data want(drop=p);
set have;
p=findc(addr,'/','b');
addr1=substr(addr, 1, p-1);
addr2=left(substr(addr, p+1));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I used the LEFT function to ensure that ADDR2 does not contain leading blanks. Feel free to define shorter lengths (than the default, which is the defined length of ADDR) for ADDR1 and ADDR2 with a LENGTH statement.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 15:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806327#M317662</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-04-06T15:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: Scan multiple Delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806347#M317678</link>
      <description>That's an efficient solution. Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 06 Apr 2022 17:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806347#M317678</guid>
      <dc:creator>Deb4</dc:creator>
      <dc:date>2022-04-06T17:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Scan multiple Delimiter</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806349#M317680</link>
      <description>Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 06 Apr 2022 17:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scan-multiple-Delimiter/m-p/806349#M317680</guid>
      <dc:creator>Deb4</dc:creator>
      <dc:date>2022-04-06T17:11:34Z</dc:date>
    </item>
  </channel>
</rss>

