<?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 using SCAN in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/using-SCAN/m-p/786548#M38567</link>
    <description>&lt;P&gt;I inherited an xlsx file with one particularly irksome field -&amp;gt; guardians&lt;/P&gt;
&lt;P&gt;data I have:&lt;/P&gt;
&lt;P&gt;&lt;U&gt;guardians&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Smith, Joe Smith, Jane&lt;/P&gt;
&lt;P&gt;Jones, Bill Jones, Pat&lt;/P&gt;
&lt;P&gt;Wells, Donna&lt;/P&gt;
&lt;P&gt;I want to create a first and last name for each person. This is the code I used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data pt3;
set pt2;
Lguard_1=scan(guardians,1,',');
Fguard_1=scan(guardians,2,' ');
Lguard_2=scan(guardians,-2,' ');
Fguard_2=scan(guardians,-1,' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;data I now have:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Lguard_1&amp;nbsp; &amp;nbsp; Fguard_1&amp;nbsp; &amp;nbsp; &amp;nbsp;Lguard_2&amp;nbsp; &amp;nbsp; Fguard_2&lt;/P&gt;
&lt;P&gt;Smith&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Joe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Smith,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jane&lt;/P&gt;
&lt;P&gt;Jones&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Bill&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Jones,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pat&lt;/P&gt;
&lt;P&gt;Wells&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Donna&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Wells,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Donna &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 things: 1) i need to get rid of the pesky comma in Lguard_2 and 2) I don't want to repeat a single parent/guardian name such as obs 3.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Dec 2021 19:23:06 GMT</pubDate>
    <dc:creator>GreggB</dc:creator>
    <dc:date>2021-12-17T19:23:06Z</dc:date>
    <item>
      <title>using SCAN</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/using-SCAN/m-p/786548#M38567</link>
      <description>&lt;P&gt;I inherited an xlsx file with one particularly irksome field -&amp;gt; guardians&lt;/P&gt;
&lt;P&gt;data I have:&lt;/P&gt;
&lt;P&gt;&lt;U&gt;guardians&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Smith, Joe Smith, Jane&lt;/P&gt;
&lt;P&gt;Jones, Bill Jones, Pat&lt;/P&gt;
&lt;P&gt;Wells, Donna&lt;/P&gt;
&lt;P&gt;I want to create a first and last name for each person. This is the code I used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data pt3;
set pt2;
Lguard_1=scan(guardians,1,',');
Fguard_1=scan(guardians,2,' ');
Lguard_2=scan(guardians,-2,' ');
Fguard_2=scan(guardians,-1,' ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;data I now have:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;Lguard_1&amp;nbsp; &amp;nbsp; Fguard_1&amp;nbsp; &amp;nbsp; &amp;nbsp;Lguard_2&amp;nbsp; &amp;nbsp; Fguard_2&lt;/P&gt;
&lt;P&gt;Smith&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Joe&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Smith,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Jane&lt;/P&gt;
&lt;P&gt;Jones&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Bill&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Jones,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Pat&lt;/P&gt;
&lt;P&gt;Wells&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Donna&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Wells,&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Donna &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2 things: 1) i need to get rid of the pesky comma in Lguard_2 and 2) I don't want to repeat a single parent/guardian name such as obs 3.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 19:23:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/using-SCAN/m-p/786548#M38567</guid>
      <dc:creator>GreggB</dc:creator>
      <dc:date>2021-12-17T19:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: using SCAN</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/using-SCAN/m-p/786551#M38568</link>
      <description>&lt;P&gt;To properly be able to scan such a field you need something other than SPACE between two names.&lt;/P&gt;
&lt;PRE&gt;Smith, Joe|Smith, Jane&lt;/PRE&gt;
&lt;P&gt;Then you could get the two separate names easily using SCAN().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;G1=scan(guardians,1,'|');
G2=scan(guardians,2,'|');
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With your current values you could try removing the space after the comma.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;G1=scan(tranwrd(guardians,', ',','),1,' ');
G2=scan(tranwrd(guardians,', ',','),2,' ')
Lguard_1=scan(G1,1,',');
Fguard_1=scan(G1,2,',');
Lguard_2=scan(G2,1,',');
Fguard_2=scan(G2,2,',');
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you will still have trouble with first or last names that include a space.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 20:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/using-SCAN/m-p/786551#M38568</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-17T20:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: using SCAN</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/using-SCAN/m-p/786553#M38569</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if countc(guardians,",") = 2
then do;
  Lguard_2=compress(scan(guardians,-2,' '),",");
  Fguard_2=scan(guardians,-1,' ');
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Dec 2021 20:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/using-SCAN/m-p/786553#M38569</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-17T20:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: using SCAN</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/using-SCAN/m-p/786580#M38571</link>
      <description>&lt;P&gt;As long as you don't have two words as a first name (Jo Ann) or last name (van Gogh), you can do this with slight modification to your code.&amp;nbsp; You now have:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Lguard_1=scan(guardians,1,',');
Fguard_1=scan(guardians,2,' ');
Lguard_2=scan(guardians,-2,' ');
Fguard_2=scan(guardians,-1,' ');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead, use both blanks and commas as delimiters:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Lguard_1=scan(guardians, 1, ' ,');
Fguard_1=scan(guardians, 2, ' ,');
Lguard_2=scan(guardians, 3, ' ,');
Fguard_2=scan(guardians, 4, ' ,');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When there is only one guardian, the third and fourth words will be blank and therefore Lguard_2 and Fguard_2 will also be blank.&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2021 04:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/using-SCAN/m-p/786580#M38571</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-12-18T04:31:53Z</dc:date>
    </item>
  </channel>
</rss>

