<?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 Check if multiple columns differ each other in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-if-multiple-columns-differ-each-other/m-p/875993#M346121</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have dynamic data set that can have different number of column .&lt;/P&gt;
&lt;P&gt;Some of the columns in the data set have name with similar strcuture&amp;nbsp; Mon1,Mon2,Mon3&amp;nbsp; and so on.&lt;/P&gt;
&lt;P&gt;As I said before number of columns with name Mon is not fixed.&lt;/P&gt;
&lt;P&gt;I want to create a new column called "Indicator" which will get value 1 if there are at least 2 column with different values in column Mon1,Mon2,Mon3 and so on.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;If there are 3 columns then the condition is :&lt;/P&gt;
&lt;P&gt;IF Mon2 ne Mon1 OR Mon3 ne Mon2 then Indicator=1;else&amp;nbsp;Indicator=0;&lt;/P&gt;
&lt;P&gt;My question:&lt;/P&gt;
&lt;P&gt;What is the way to create dynamic code that calculate column "Indicator" based on any number of columns Mon1,Mon2,Mon3....&lt;/P&gt;
&lt;P&gt;Please note that the values in&amp;nbsp;columns Mon1,Mon2,Mon3 are chars&amp;nbsp; with long string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2023 13:24:29 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2023-05-16T13:24:29Z</dc:date>
    <item>
      <title>Check if multiple columns differ each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-multiple-columns-differ-each-other/m-p/875993#M346121</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have dynamic data set that can have different number of column .&lt;/P&gt;
&lt;P&gt;Some of the columns in the data set have name with similar strcuture&amp;nbsp; Mon1,Mon2,Mon3&amp;nbsp; and so on.&lt;/P&gt;
&lt;P&gt;As I said before number of columns with name Mon is not fixed.&lt;/P&gt;
&lt;P&gt;I want to create a new column called "Indicator" which will get value 1 if there are at least 2 column with different values in column Mon1,Mon2,Mon3 and so on.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;If there are 3 columns then the condition is :&lt;/P&gt;
&lt;P&gt;IF Mon2 ne Mon1 OR Mon3 ne Mon2 then Indicator=1;else&amp;nbsp;Indicator=0;&lt;/P&gt;
&lt;P&gt;My question:&lt;/P&gt;
&lt;P&gt;What is the way to create dynamic code that calculate column "Indicator" based on any number of columns Mon1,Mon2,Mon3....&lt;/P&gt;
&lt;P&gt;Please note that the values in&amp;nbsp;columns Mon1,Mon2,Mon3 are chars&amp;nbsp; with long string&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 13:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-multiple-columns-differ-each-other/m-p/875993#M346121</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2023-05-16T13:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Check if multiple columns differ each other</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-if-multiple-columns-differ-each-other/m-p/876001#M346125</link>
      <description>&lt;P&gt;When the number of columns can vary, but with relatively consistent naming conventions, then use ARRAY statement. This code is UNTESTED as you have not provided data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    array mon mon:;
    indicator=0;
    do i=2 to dim(mon);
        if mon(1)^=mon(i) then do;
            indicator=1;
            leave;
       end;
    end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 15:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-if-multiple-columns-differ-each-other/m-p/876001#M346125</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-16T15:24:15Z</dc:date>
    </item>
  </channel>
</rss>

