<?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: Concatenate in PROC SQL (CAT) returning null values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784467#M250346</link>
    <description>Ahh, thanks for putting it that way. That makes sense!</description>
    <pubDate>Tue, 07 Dec 2021 05:09:08 GMT</pubDate>
    <dc:creator>InspectahDex</dc:creator>
    <dc:date>2021-12-07T05:09:08Z</dc:date>
    <item>
      <title>Concatenate in PROC SQL (CAT) returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784433#M250329</link>
      <description>&lt;P&gt;I'm trying to concatenate firstname, middlename, lastname, and professionaltitle columns to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;John David Smith, MD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I try the below cat function within my PROC SQL statement, I get a column that is completely blank with null values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;cat(PROVIDER_FIRST_NAME, " ", PROVIDER_MIDDLE_NAME, " ", PROVIDER_LAST_NAME, ", ", PROF_DESIGNATION) as provider_name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The CATT, CATS, and CATX functions return values as expected but I'm stumped as to why the CAT function returns nothing.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 01:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784433#M250329</guid>
      <dc:creator>InspectahDex</dc:creator>
      <dc:date>2021-12-07T01:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate in PROC SQL (CAT) returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784434#M250330</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121262"&gt;@InspectahDex&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CATT, CATS, and CATX functions return values as expected but I'm stumped as to why the CAT function returns nothing.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The other functions trim (remove blank spaces) by default and CAT does not.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this work for you:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cat(trim(PROVIDER_FIRST_NAME), " ", trim(PROVIDER_MIDDLE_NAME), " ", trim(PROVIDER_LAST_NAME), ", ", trim(PROF_DESIGNATION)) as provider_name&lt;/CODE&gt;&lt;/PRE&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/121262"&gt;@InspectahDex&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to concatenate firstname, middlename, lastname, and professionaltitle columns to look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;John David Smith, MD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However when I try the below cat function within my PROC SQL statement, I get a column that is completely blank with null values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cat(PROVIDER_FIRST_NAME, " ", PROVIDER_MIDDLE_NAME, " ", PROVIDER_LAST_NAME, ", ", PROF_DESIGNATION) as provider_name&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The CATT, CATS, and CATX functions return values as expected but I'm stumped as to why the CAT function returns nothing.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 01:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784434#M250330</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-07T01:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate in PROC SQL (CAT) returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784458#M250339</link>
      <description>&lt;P&gt;CAT() does this (assuming the variable lengths here):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'John                                                                 ' || &lt;BR /&gt;'David                                                                ' ||&lt;BR /&gt;'Smith                                                                ' ||&lt;BR /&gt;', ' ||&lt;BR /&gt;'MD                                                                   '&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which does not fit in your result variable.&lt;BR /&gt;If&amp;nbsp;&lt;SPAN&gt;PROVIDER_FIRST_NAME is empty, you may well run out of space to see anything at all.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 03:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784458#M250339</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-12-07T03:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate in PROC SQL (CAT) returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784460#M250341</link>
      <description>&lt;P&gt;Hard to tell without seeing the context you are using this.&lt;/P&gt;
&lt;P&gt;But the CAT() function is inappropriate for what you are doing.&lt;/P&gt;
&lt;P&gt;You will not get&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;John David Smith, MD&lt;/PRE&gt;
&lt;P&gt;as the result unless&amp;nbsp;PROVIDER_FIRST_NAME is defined as length $4 and PROVIDER_MIDDLE_NAME is defined as length $5 and PROVIDER_LAST_NAME is defined as length $5 and PROF_DESIGNATION is defined as length equal to longer than $2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is because the CAT() function, unlike the other functions you mentioned, does NOT trim the trailing spaces from the fixed length character strings that SAS uses.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 03:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784460#M250341</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-12-07T03:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate in PROC SQL (CAT) returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784466#M250345</link>
      <description>It does but another issue is popping up. When the provider has no middle name, there are 3 spaces instead of 1 because of that rule. Is there anyway to account to have a single space for instances where a middle name value is null?</description>
      <pubDate>Tue, 07 Dec 2021 05:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784466#M250345</guid>
      <dc:creator>InspectahDex</dc:creator>
      <dc:date>2021-12-07T05:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate in PROC SQL (CAT) returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784467#M250346</link>
      <description>Ahh, thanks for putting it that way. That makes sense!</description>
      <pubDate>Tue, 07 Dec 2021 05:09:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784467#M250346</guid>
      <dc:creator>InspectahDex</dc:creator>
      <dc:date>2021-12-07T05:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate in PROC SQL (CAT) returning null values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784468#M250347</link>
      <description>I found a solution to that second issue. I just added compbl before the (cat(trim... and it worked! Thanks, Reeza!</description>
      <pubDate>Tue, 07 Dec 2021 05:17:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-in-PROC-SQL-CAT-returning-null-values/m-p/784468#M250347</guid>
      <dc:creator>InspectahDex</dc:creator>
      <dc:date>2021-12-07T05:17:25Z</dc:date>
    </item>
  </channel>
</rss>

