<?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: Check and combine multiple columns into one in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359548#M23666</link>
    <description>The current solution will suffice for the moment, and I agree with you that a macro could be a better option.</description>
    <pubDate>Thu, 18 May 2017 06:03:04 GMT</pubDate>
    <dc:creator>ayin</dc:creator>
    <dc:date>2017-05-18T06:03:04Z</dc:date>
    <item>
      <title>Check and combine multiple columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359518#M23661</link>
      <description>&lt;P&gt;To generate datasets needed:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input word_a $ word_b $ WoRD_c $ ignore_d $;
datalines;
. Test TEST ignore
;
run;

data want;
  input WORD $ ignore_d $ WORD_IND;
datalines;
TEST ignore 0
;
run;

data have2;
  input num_a num_b Num_c ignore_d $;
datalines;
. 2 3 ignore
;
run;

data want2;
  input NUM ignore_d $ NUM_IND;
datalines;
. ignore 1
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;From dataset 'have' to 'want':&lt;/P&gt;&lt;P&gt;there are 3 columns whose names have 'word' inside, need to compare the values. If the &lt;U&gt;values are the same&lt;/U&gt; (after upcase it, and ignoring blank value), then output a single column named 'WORD' and the indicator 'WORD_IND' is 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From dataset 'have2' to 'want2':&lt;/P&gt;&lt;P&gt;there are 3 columns whose names have 'num' inside, compare the values. Because the &lt;U&gt;values are not the same&lt;/U&gt; (ignoring blank value), output a single column named 'NUM' but with blank value, and the indicator 'NUM_IND' is 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to achieve it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 23:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359518#M23661</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-05-17T23:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Check and combine multiple columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359529#M23662</link>
      <description>&lt;P&gt;Do you have only the two variables that will be created, Word or NUM or will it depend on the field?&lt;/P&gt;
&lt;P&gt;If the variable name created is dependent on the data&amp;nbsp;you're going to need a macro.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 01:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359529#M23662</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-18T01:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Check and combine multiple columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359532#M23663</link>
      <description>Hey Reeza,&lt;BR /&gt;Yes I have only the two variables that will be created.</description>
      <pubDate>Thu, 18 May 2017 01:41:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359532#M23663</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-05-18T01:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Check and combine multiple columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359535#M23664</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*dataset 1*/
data have;
  input word_a $ word_b $ WoRD_c $ ignore_d $;
datalines;
unk Test TEST ignore
;
run;

data want1;
set have;
array wrd word_a  word_b  WoRD_c;
do over wrd;
wrd=upcase(wrd);
end;
run;

data want2;
set want1;
call sortc (of word:);
word_ind= ifc(coalescec(of word:) eq word_c, '0' , '1');
set want1;
run;

/*dataset 2*/
data have2;
  input num_a num_b Num_c ignore_d $;
datalines;
. 2 3 ignore
;
run;

data want2;
set have2;
call sortn (of num:);
NUM_IND = ifn(coalescec(of num:) eq num_c, 0 , 1);
set have2;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 May 2017 02:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359535#M23664</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-05-18T02:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: Check and combine multiple columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359540#M23665</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/120587"&gt;@ayin&lt;/a&gt;&amp;nbsp;How much information will you have ahead of time or do you need a solution as provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12151"&gt;@Jagadishkatam&lt;/a&gt;. Also, do you have only the three words or is there a possibility&amp;nbsp;of more variables to check?&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2017 03:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359540#M23665</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-18T03:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Check and combine multiple columns into one</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359548#M23666</link>
      <description>The current solution will suffice for the moment, and I agree with you that a macro could be a better option.</description>
      <pubDate>Thu, 18 May 2017 06:03:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Check-and-combine-multiple-columns-into-one/m-p/359548#M23666</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-05-18T06:03:04Z</dc:date>
    </item>
  </channel>
</rss>

