<?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 Coalesece in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Coalesece/m-p/684777#M207576</link>
    <description>&lt;P&gt;Using SAS 9.4&lt;/P&gt;
&lt;P&gt;I am running the following code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;input a $ b $ c $;&lt;BR /&gt;datalines;&lt;BR /&gt;one two three&lt;BR /&gt;one two three&lt;BR /&gt;one two three&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data check2(drop=i);&lt;BR /&gt;set want;&lt;BR /&gt;length mme $ 500;&lt;BR /&gt;array tots _character_;&lt;BR /&gt;do i = 1 to dim(tots);&lt;BR /&gt;if tots[i] ne '' then do;&lt;BR /&gt;mme = catx(',', mme, coalescec(tots[i]));&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 3 character variables that I am trying to combine all possible combinations and separate with a ",". However, when I run this code it repeats the combination twice. Is there a way to get the data to not repeat the second time? Thank you&lt;/P&gt;</description>
    <pubDate>Thu, 17 Sep 2020 19:42:43 GMT</pubDate>
    <dc:creator>GS2</dc:creator>
    <dc:date>2020-09-17T19:42:43Z</dc:date>
    <item>
      <title>Coalesece</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesece/m-p/684777#M207576</link>
      <description>&lt;P&gt;Using SAS 9.4&lt;/P&gt;
&lt;P&gt;I am running the following code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;input a $ b $ c $;&lt;BR /&gt;datalines;&lt;BR /&gt;one two three&lt;BR /&gt;one two three&lt;BR /&gt;one two three&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data check2(drop=i);&lt;BR /&gt;set want;&lt;BR /&gt;length mme $ 500;&lt;BR /&gt;array tots _character_;&lt;BR /&gt;do i = 1 to dim(tots);&lt;BR /&gt;if tots[i] ne '' then do;&lt;BR /&gt;mme = catx(',', mme, coalescec(tots[i]));&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have 3 character variables that I am trying to combine all possible combinations and separate with a ",". However, when I run this code it repeats the combination twice. Is there a way to get the data to not repeat the second time? Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 19:42:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesece/m-p/684777#M207576</guid>
      <dc:creator>GS2</dc:creator>
      <dc:date>2020-09-17T19:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesece</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesece/m-p/684780#M207578</link>
      <description>&lt;P&gt;Put the&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; length mme $ 500;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;statement AFTER the&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; array tots _character_;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise the array includes MME, explaining your unexpected results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The compiler interprets _character_ and _numeric_ (and _all_) based on the variables it knows about at the point in the code that they appear.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Sep 2020 19:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesece/m-p/684780#M207578</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-09-17T19:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Coalesece</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coalesece/m-p/684785#M207583</link>
      <description>&lt;P&gt;The problem is that when you say&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array tots _character_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;variable mme is already defined and thus is included in the list of _character_ variables referenced by array tots. So the simple solution is to define the array sooner:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check2(drop=i);
set want;
array tots _character_;
length mme $ 500;
do i = 1 to dim(tots);
    if tots[i] ne '' then do;
        mme = catx(',', mme, coalescec(tots[i]));
        end;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that you could also do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check3(drop=i);
set want;
array tots _character_;
length mme $ 500;
mme = catx(",", of tots[*]);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Sep 2020 20:04:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coalesece/m-p/684785#M207583</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-09-17T20:04:14Z</dc:date>
    </item>
  </channel>
</rss>

