<?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 concatenate 2 columns and have the output read into an existing column? in SAS Software for Learning Community</title>
    <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901486#M1543</link>
    <description>&lt;P&gt;You might try&lt;/P&gt;
&lt;PRE&gt;proc SQL; 
SELECT
  coalescec( name, catx(' ',Last_Name , First_Name))  AS Name
FROM work.table1;

run;&lt;/PRE&gt;
&lt;P&gt;The COALESCEC function, and its partner Coalesce for numeric variables, returns as the result the first value in the list of values provided. So if Name is blank the result of the catx function is returned. I use CATX because it will strip extra spaces from the parameters an place only one space, if needed, between the last and first names.&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/207689"&gt;@JibJam221&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a table that consists of 3 columns: "Name" "FirstName" "LastName".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "name" column is half filled, the other half is blank.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "firstname" and "lastname" columns have the other half of the data. I'd like to concatenate these two columns and have the output placed into the "name" column where the values are empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc SQL; 
SELECT
  Last_Name || ' ' || First_Name AS Name
FROM work.table1;

run;&lt;/PRE&gt;
&lt;P&gt;this is what I have for the concatenation of the 2 columns, but im not sure how I can write in to have this placed into the NAME column when the value is empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any advice is appreciated,&lt;/P&gt;
&lt;P&gt;thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Nov 2023 13:49:15 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-11-06T13:49:15Z</dc:date>
    <item>
      <title>How to concatenate 2 columns and have the output read into an existing column?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901471#M1541</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a table that consists of 3 columns: "Name" "FirstName" "LastName".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "name" column is half filled, the other half is blank.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "firstname" and "lastname" columns have the other half of the data. I'd like to concatenate these two columns and have the output placed into the "name" column where the values are empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc SQL; 
SELECT
  Last_Name || ' ' || First_Name AS Name
FROM work.table1;

run;&lt;/PRE&gt;
&lt;P&gt;this is what I have for the concatenation of the 2 columns, but im not sure how I can write in to have this placed into the NAME column when the value is empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any advice is appreciated,&lt;/P&gt;
&lt;P&gt;thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 19:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901471#M1541</guid>
      <dc:creator>JibJam221</dc:creator>
      <dc:date>2023-11-03T19:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate 2 columns and have the output read into an existing column?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901477#M1542</link>
      <description>&lt;P&gt;Please provide a few examples.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 19:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901477#M1542</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-03T19:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate 2 columns and have the output read into an existing column?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901486#M1543</link>
      <description>&lt;P&gt;You might try&lt;/P&gt;
&lt;PRE&gt;proc SQL; 
SELECT
  coalescec( name, catx(' ',Last_Name , First_Name))  AS Name
FROM work.table1;

run;&lt;/PRE&gt;
&lt;P&gt;The COALESCEC function, and its partner Coalesce for numeric variables, returns as the result the first value in the list of values provided. So if Name is blank the result of the catx function is returned. I use CATX because it will strip extra spaces from the parameters an place only one space, if needed, between the last and first names.&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/207689"&gt;@JibJam221&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a table that consists of 3 columns: "Name" "FirstName" "LastName".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "name" column is half filled, the other half is blank.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "firstname" and "lastname" columns have the other half of the data. I'd like to concatenate these two columns and have the output placed into the "name" column where the values are empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc SQL; 
SELECT
  Last_Name || ' ' || First_Name AS Name
FROM work.table1;

run;&lt;/PRE&gt;
&lt;P&gt;this is what I have for the concatenation of the 2 columns, but im not sure how I can write in to have this placed into the NAME column when the value is empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any advice is appreciated,&lt;/P&gt;
&lt;P&gt;thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 13:49:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901486#M1543</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-11-06T13:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate 2 columns and have the output read into an existing column?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901721#M1546</link>
      <description>&lt;P&gt;for sure!&lt;/P&gt;
&lt;P&gt;Current Table:&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="348"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="116"&gt;Fitst Name&lt;/TD&gt;
&lt;TD width="116"&gt;Last Name&lt;/TD&gt;
&lt;TD width="116"&gt;Name&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Marsha Jones&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;John&lt;/TD&gt;
&lt;TD&gt;Doe&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Jane&lt;/TD&gt;
&lt;TD&gt;Levis&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Marianne Phil&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Marsha Jones&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Mandy&lt;/TD&gt;
&lt;TD&gt;Smith&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Thomas Cruz&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired table:&lt;/P&gt;
&lt;TABLE width="114px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="113.082px" height="30px"&gt;Name&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="113.082px" height="30px"&gt;Marsha Jones&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="113.082px" height="30px"&gt;John Doe&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="113.082px" height="30px"&gt;Jane Levis&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="113.082px" height="30px"&gt;Marianne Phil&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="113.082px" height="30px"&gt;Marsha Jones&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="113.082px" height="30px"&gt;Mandy Smith&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="113.082px" height="30px"&gt;Thomas Cruz&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So im looking for a code that can concatenate the "first name" and "last name" columns, and insert the values into the pre-existing 'Name' Column, wherever there are blanks.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 13:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901721#M1546</guid>
      <dc:creator>JibJam221</dc:creator>
      <dc:date>2023-11-06T13:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate 2 columns and have the output read into an existing column?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901722#M1547</link>
      <description>&lt;P&gt;this code concatenates, however the output is into a whole new column instead of the pre-existing name column. the "name" column has some names in it already, and i'd like the first name &amp;amp; last name values to be inserted into the "name" column where there are blanks&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 13:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901722#M1547</guid>
      <dc:creator>JibJam221</dc:creator>
      <dc:date>2023-11-06T13:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate 2 columns and have the output read into an existing column?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901723#M1548</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    if missing(name) then name=catx(' ',first_name,last_name);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2023 13:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901723#M1548</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-06T13:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to concatenate 2 columns and have the output read into an existing column?</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901724#M1549</link>
      <description>&lt;P&gt;Assuming NAME is defined long enough and the pattern of either NAME having a value or the other two having values is consistent then just replace name with combination of all three.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  name=catx(' ',name,firstname,lastname);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If NAME is not long enough then change it s length first.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length name $100 ;
  set have;
  name=catx(' ',name,firstname,lastname);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Nov 2023 13:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/How-to-concatenate-2-columns-and-have-the-output-read-into-an/m-p/901724#M1549</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-11-06T13:52:31Z</dc:date>
    </item>
  </channel>
</rss>

