<?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: Scanning for multiple spaces in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488950#M127525</link>
    <description>&lt;P&gt;I tried the following&amp;nbsp;and no luck..&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;BOR1_LASTNAME = trim(scan(BOR1_FULL_NAME_COR,1,'09'x));&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Aug 2018 15:49:51 GMT</pubDate>
    <dc:creator>camfarrell25</dc:creator>
    <dc:date>2018-08-22T15:49:51Z</dc:date>
    <item>
      <title>Scanning for multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488942#M127521</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to use the scan function to distinguish between first and last name, which are separated by a longer space. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HOGUE STAUBIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BENOIT G&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;BOR1_LASTNAME = trim(scan(BOR1_FULL_NAME_COR,&lt;/FONT&gt;&lt;FONT color="#804040" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT color="#442db3" face="Courier New" size="3"&gt;"&amp;nbsp;&amp;nbsp; "&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Breaks it down by: &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;HOGUE&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;When the result I would want is: HOGUE STAUBIN&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Note that there's some instances where the last name is composed (two names) and sometimes single, but the first and last name(s) are always separated by a longer space. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Any insights? &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 15:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488942#M127521</guid>
      <dc:creator>camfarrell25</dc:creator>
      <dc:date>2018-08-22T15:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning for multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488944#M127522</link>
      <description>&lt;P&gt;Look into the modifiers (m) for the SCAN() function.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0jshdjy2z9zdzn1h7k90u99lyq6.htm&amp;amp;locale=en#n1b0x6tlw5ztlzn1j6bclhsvc8ia" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0jshdjy2z9zdzn1h7k90u99lyq6.htm&amp;amp;locale=en#n1b0x6tlw5ztlzn1j6bclhsvc8ia&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/81770"&gt;@camfarrell25&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am trying to use the scan function to distinguish between first and last name, which are separated by a longer space. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HOGUE STAUBIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BENOIT G&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following code&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;BOR1_LASTNAME = trim(scan(BOR1_FULL_NAME_COR,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#804040"&gt;1&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#442db3"&gt;"&amp;nbsp;&amp;nbsp; "&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Breaks it down by: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;HOGUE&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;When the result I would want is: HOGUE STAUBIN&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Note that there's some instances where the last name is composed (two names) and sometimes single, but the first and last name(s) are always separated by a longer space. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Any insights? &lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 15:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488944#M127522</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-22T15:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning for multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488948#M127524</link>
      <description>Any chance your delimiter is actually a tab? Can you use '09'x to see if it's a tab or verify in a text editor?</description>
      <pubDate>Wed, 22 Aug 2018 15:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488948#M127524</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-22T15:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning for multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488950#M127525</link>
      <description>&lt;P&gt;I tried the following&amp;nbsp;and no luck..&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;BOR1_LASTNAME = trim(scan(BOR1_FULL_NAME_COR,1,'09'x));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Aug 2018 15:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488950#M127525</guid>
      <dc:creator>camfarrell25</dc:creator>
      <dc:date>2018-08-22T15:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning for multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488951#M127526</link>
      <description>&lt;P&gt;Is this from a text file? Can you upload a small sample? Pasting as text may remove issues in the actual data unfortunately.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 15:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488951#M127526</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-22T15:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning for multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488956#M127529</link>
      <description>&lt;P&gt;It's not pulled from a text file - see attached. Essentially the logic that would work is to be able to separate the first and last name in two if the space between them exceeds one, and then further breaking it down into first last name, and second last name based on the presence of a single space.&lt;/P&gt;&lt;P&gt;Is there a way?&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 15:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488956#M127529</guid>
      <dc:creator>camfarrell25</dc:creator>
      <dc:date>2018-08-22T15:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning for multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488966#M127531</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/81770"&gt;@camfarrell25&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It's not pulled from a text file - see attached. Essentially the logic that would work is to be able to separate the first and last name in two if the space between them exceeds one, and then further breaking it down into first last name, and second last name based on the presence of a single space.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Is there a way?&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm assuming you're actually asking how, rather than if it's possible, otherwise the answer is yes.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use FINDW to find a string of two spaces, then use SUBSTR at that location.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also used STRIP to remove any leading spaces from the second portion.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    text1 = "HOGUE STAUBIN      BENOIT G";
    x=findw(text1, "  ");
    p1 = substr(text1, 1, x);
    p2 = strip(substr(text1, x+1));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Aug 2018 16:24:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/488966#M127531</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-08-22T16:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning for multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/489010#M127545</link>
      <description>&lt;P&gt;Can you post more data as text? I won't open ms office files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following regular expression can help solving the problem:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    text1 = "HOGUE STAUBIN      BENOIT G";
    rx = prxparse('/(\w+ \w*) +.*/');
    
    if prxmatch(rx, trim(text1)) then do;
    	last_name = prxposn(rx, 1, text1);
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Aug 2018 19:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/489010#M127545</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-08-22T19:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Scanning for multiple spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/489020#M127548</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm sorry - find attach text file.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;CF&lt;/P&gt;</description>
      <pubDate>Wed, 22 Aug 2018 19:37:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Scanning-for-multiple-spaces/m-p/489020#M127548</guid>
      <dc:creator>camfarrell25</dc:creator>
      <dc:date>2018-08-22T19:37:00Z</dc:date>
    </item>
  </channel>
</rss>

