<?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: First person name and Second person name and last person name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389923#M277579</link>
    <description>&lt;P&gt;So do you want commas and the word AND as part of the result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, does it matter if you have a comma before the word AND?&lt;/P&gt;</description>
    <pubDate>Tue, 22 Aug 2017 17:09:09 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-08-22T17:09:09Z</dc:date>
    <item>
      <title>First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389896#M277575</link>
      <description>&lt;P&gt;I have a requirment like below..may i know if any one have handy code ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If First_Name1 is populated only then result = first_name1 &lt;BR /&gt;First_Name1 and First_Name2 are populated only then result = first_name1 AND first_name2&lt;BR /&gt;First_Name1 ,First_Name2 , first_name3 are populated only then result = first_name1 , first_name2 AND first_name3&lt;BR /&gt;First_Name1 ,First_Name2 , first_name3,first_name4 are populated only then result = first_name1 , first_name2 ,first_name3 AND first_name4&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 16:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389896#M277575</guid>
      <dc:creator>mmkr</dc:creator>
      <dc:date>2017-08-22T16:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389906#M277576</link>
      <description>&lt;P&gt;I think this is unfortunately a bit of manual IF/THEN as you've pseudo coded below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use CATX() to help string the variables together and you can create an array and count the components to determine which rules need to be followed.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 16:48:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389906#M277576</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-22T16:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389912#M277577</link>
      <description>&lt;P&gt;This probably comes close enough:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;result = catx(' ', first_name1, first_name2, first_name3, firstname4);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What result would you like if only first_name2 and first_name4 are populated?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 16:54:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389912#M277577</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-22T16:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389922#M277578</link>
      <description>&lt;P&gt;If only&amp;nbsp;&lt;SPAN&gt;first_name2 and first_name4 are populated then i need first_name 2 and frist_name4&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example 1 :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 1: Jon&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 2 : Dan&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 3 : Tam&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Frist Name 4 : Brad&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Result : Jon,Dan,Tam AND Brad&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example 2 :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 1: Jon&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 2 : Dan&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 3 : Tam&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Result : Jon,Dan AND&amp;nbsp;Tam&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example 3 :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 1: Jon&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 2 : Dan&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Result : Jon AND&amp;nbsp;Dan&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example 4 :&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 1: Jon&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 2 :&amp;nbsp;blank&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 3 : blank&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Frist Name 4 : blank&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Result : Jon&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example 5:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 1:&amp;nbsp;blank&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 2 : Adam&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First Name 3 :&amp;nbsp;blank&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Frist Name 4 : Brad&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Result : Adam AND Brad&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 17:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389922#M277578</guid>
      <dc:creator>mmkr</dc:creator>
      <dc:date>2017-08-22T17:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389923#M277579</link>
      <description>&lt;P&gt;So do you want commas and the word AND as part of the result?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, does it matter if you have a comma before the word AND?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 17:09:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389923#M277579</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-22T17:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389927#M277580</link>
      <description>&lt;P&gt;Yes I&amp;nbsp;do want commas and the word AND as part of the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think that's fine&amp;nbsp;&lt;SPAN&gt;comma before the word AND , I can remove later&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 17:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389927#M277580</guid>
      <dc:creator>mmkr</dc:creator>
      <dc:date>2017-08-22T17:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389942#M277581</link>
      <description>&lt;P&gt;OK, this looks reasonable then.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;result = catx(', ', first_name1, first_name2, first_name3, first_name4);&lt;/P&gt;
&lt;P&gt;if index(result, ',') then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; last_piece = scan(result, -1, ',');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; result = substr(result, 1, length(result) - (length(last_piece) + 2) ) || ' AND ' || last_piece);&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's untested, so you'll need to see how close this gets to what you want.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 17:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389942#M277581</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-22T17:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389951#M277582</link>
      <description>&lt;P&gt;thank you so much !!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the working one ..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test1;&lt;BR /&gt;infile cards dsd missover;&lt;BR /&gt;input f1$ f2$ f3$ f4$ ;&lt;BR /&gt;cards;&lt;BR /&gt;f1, f2, f3, f4&lt;BR /&gt;f1, f2, f3,&lt;BR /&gt;f1, f2,,&lt;BR /&gt;f1, f2, f3, f4&lt;BR /&gt;f1,,,&lt;BR /&gt;f1, f2, f3,&lt;BR /&gt;, f2, , f4&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set test1;&lt;BR /&gt;result = catx(', ', f1, f2, f3, f4);&lt;BR /&gt;if index(result, ',') then do;&lt;BR /&gt; last_piece = scan(result, -1, ',');&lt;BR /&gt; result_new = catt(substr(result, 1, length(result) - (length(last_piece) + 1) ),' AND',last_piece) ;&lt;BR /&gt;end;&lt;BR /&gt;if result_new = '' then result_new = catt(result,',');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 17:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389951#M277582</guid>
      <dc:creator>mmkr</dc:creator>
      <dc:date>2017-08-22T17:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389957#M277583</link>
      <description>You really should mark someone else's answer as the full solution, not your own post.</description>
      <pubDate>Tue, 22 Aug 2017 18:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389957#M277583</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-22T18:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389969#M277584</link>
      <description>&lt;P&gt;how can i do now ? i don't see that option now..&lt;/P&gt;
&lt;P&gt;can you pleasde advise ?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 18:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389969#M277584</guid>
      <dc:creator>mmkr</dc:creator>
      <dc:date>2017-08-22T18:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389971#M277585</link>
      <description>&lt;P&gt;Assuming all names are strings either empty (Blanks space) or strings that do not include any space&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  length name1-name5 $8;
  name1 = 'aaa';
  name2 = 'bbbbb';
  name3 = '';
  name4 = 'dddd';
  name5 = '  ';
run;
data test;
 set have;
  result = translate(compbl(catx(' ',name1,name2,name3,name4,name5)),',' , ' ');
  last_comma = findc(result,',','B');
  if last_comma &amp;gt; 0 then 
     result = substr(result,1,last_comma -1)||' and '||substr(result,last_comma +1);
  drop name1-name5;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Aug 2017 18:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/389971#M277585</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-08-22T18:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: First person name and Second person name and last person name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/390977#M277586</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Your solution works very well, but if something can be reduced to a single expression instead of several statements, it can also be used in proc sql in a select statement. Here the catx function is used as input to the prxchange function, where the last comma is translated to AND:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;create table want2 as &lt;BR /&gt;&amp;nbsp; &amp;nbsp;select prxchange('s/(.*),/$1 AND/',-1,catx(', ',f1,f2,f3,f4)) as result &lt;BR /&gt;&amp;nbsp; &amp;nbsp;from test1;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is of some importance with e.g. Data Integration Studio, because it can be used in an Extract or Join Transformation insted of an extra userwritten transformation.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 16:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-person-name-and-Second-person-name-and-last-person-name/m-p/390977#M277586</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2017-08-25T16:58:58Z</dc:date>
    </item>
  </channel>
</rss>

