<?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: compare multiple columns and concat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352238#M82078</link>
    <description>&lt;P&gt;Yes,&amp;nbsp;Yes, I made a mistake.Just like you wrote it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;0;0;1;1;1;1;1;1;1;1;0&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2017 16:40:51 GMT</pubDate>
    <dc:creator>erdem_ustun</dc:creator>
    <dc:date>2017-04-21T16:40:51Z</dc:date>
    <item>
      <title>compare multiple columns and concat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352187#M82061</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a sample dataset with the following columns.&lt;BR /&gt;To compare all the columns&lt;BR /&gt;I want to do comparison with the data step.&lt;BR /&gt;Values can be empty or string or numeric&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt; informat id v1-v12 $8.;&lt;BR /&gt; input id v1-v12;&lt;BR /&gt; cards;&lt;BR /&gt;1 1 1 1 3 a b . 4 x . 2 2&lt;BR /&gt;2 4 5 h k L L A a 4 6 7 c&lt;BR /&gt;3 3 4 5 6 7 3 6 8 8 a w d&lt;BR /&gt;4 6 7 2 1 1 2 3 4 5 6 7 s&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are data for 12 months.I want to compare them in order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cats(ifc(v1=v2,'0','1')&lt;BR /&gt;cats(ifc(v2=v3,'0','1')&lt;BR /&gt;cats(ifc(v3=v4,'0','1')&lt;BR /&gt;cats(ifc(v4=v5,'0','1')&lt;BR /&gt;cats(ifc(v5=v6,'0','1')&lt;BR /&gt;cats(ifc(v6=v7,'0','1')&lt;BR /&gt;cats(ifc(v7=v8,'0','1')&lt;BR /&gt;cats(ifc(v8=v9,'0','1')&lt;BR /&gt;cats(ifc(v9=v10,'0','1')&lt;BR /&gt;cats(ifc(v10=v11,'0','1')&lt;BR /&gt;cats(ifc(v11=v12,'0','1')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At the end, a concatenated string will be formed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For id = 1 concat_compare='0;0;1;1;1;1;1;1;1;1;0' and&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;same_count=7 /* I have 3&amp;nbsp;item for 1, 2 item for 2 &amp;nbsp;and 2 item &amp;nbsp;for missing ,sum(3,2,2) */ &lt;BR /&gt;not_same_count=5&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;same_values=1;2; .; /*distinct values, Although it is not the same but more than one / If empty record exists it must be listed &amp;nbsp;*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;not_same_&lt;SPAN&gt;values&lt;/SPAN&gt;=3;a;b;4;x /*distinct values only have one */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found a code to find the number of the same on the forum.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want (drop=i j);&lt;BR /&gt; set have;&lt;BR /&gt; array vars $8. v1-v12;&lt;BR /&gt; same=0;&lt;BR /&gt; do i=1 to dim(vars)-1;&lt;BR /&gt; do j=i+1 to dim(vars);&lt;BR /&gt; same=sum (same, vars(i) eq vars(j));&lt;BR /&gt; end;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;But I could not do the others.&lt;/P&gt;
&lt;P&gt;I need the following fields on a record-based.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;concat_compare &amp;nbsp; same_count &amp;nbsp; &amp;nbsp;not_same_count &amp;nbsp; same_values &amp;nbsp; &amp;nbsp;not_same_values&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to do this for each record/id?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 17:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352187#M82061</guid>
      <dc:creator>erdem_ustun</dc:creator>
      <dc:date>2017-04-21T17:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: compare multiple columns and concat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352193#M82063</link>
      <description>&lt;P&gt;Well, your concat problem is simple and well explained, so code below. &amp;nbsp;For your other four variables however, I didn't follow at all - please clarify.&lt;/P&gt;
&lt;PRE&gt;data have;
informat id v1-v12 $8.;
input id v1-v12;
cards;
1 1 1 1 3 a b . 4 x . 2 2
2 4 5 h k L L A a 4 6 7 c
3 3 4 5 6 7 3 6 8 8 a w d
4 6 7 2 1 1 2 3 4 5 6 7 s
;
run;

data want;
  set have;
  length concat_compare $2000;
  array vals{*} v:;
  do i=1 to dim(vals)-1;
    concat_compare=catx(';',concat_compare,ifc(vals{i}=vals{i+1},"1","0")); 
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2017 14:44:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352193#M82063</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-04-21T14:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: compare multiple columns and concat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352209#M82068</link>
      <description>&lt;P&gt;for Id 1 V3=1 and v4=3. So wouldn't the result be&lt;/P&gt;
&lt;P&gt;0;0;1;1;1;1;1;1;1;1;0&lt;/P&gt;
&lt;P&gt;and not your example&lt;/P&gt;
&lt;P&gt;0;0;0;1;1;1;1;1;1;1;0&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 15:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352209#M82068</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-21T15:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: compare multiple columns and concat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352238#M82078</link>
      <description>&lt;P&gt;Yes,&amp;nbsp;Yes, I made a mistake.Just like you wrote it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;0;0;1;1;1;1;1;1;1;1;0&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 16:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352238#M82078</guid>
      <dc:creator>erdem_ustun</dc:creator>
      <dc:date>2017-04-21T16:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: compare multiple columns and concat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352249#M82082</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class="login-bold"&gt;&lt;A id="link_8" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151" target="_self"&gt;RW9&lt;/A&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="login-bold"&gt;&lt;EM&gt;I made the mistake of including id in my first post&lt;/EM&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks for your reply.I will try to explain the other four&amp;nbsp;variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;mean of &amp;nbsp;&lt;STRONG&gt;same_values&lt;/STRONG&gt; :It is a list of multiple recurring values when we accept each record as an array. so for id=1 ,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The same_values will be "1;2; . "&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;same_values="1;2; . " (missing is include)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;mean of &lt;STRONG&gt;not_same_values&lt;/STRONG&gt;:A list of values that do not repeat more than once when we accept each record as an array.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;so for id=1 , The not_same_values will be &lt;STRONG&gt;"&lt;/STRONG&gt;3;a;b;4;x"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;not_same_values="&lt;/STRONG&gt;3;a;b;4;x"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;same_count&lt;/STRONG&gt;:The number of times that multiple repeating values are repeated. It is the sum of the number of repeats&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;for example ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;for id = 1 , Repeated 1 to &lt;STRONG&gt;3&lt;/STRONG&gt; times,Repeated missing value(.)&amp;nbsp;to &lt;STRONG&gt;2&lt;/STRONG&gt;&amp;nbsp;times &amp;nbsp;Repeated 2&amp;nbsp;to &lt;STRONG&gt;2&lt;/STRONG&gt;&amp;nbsp;times and Their &lt;STRONG&gt;sum is&amp;nbsp;7&lt;/STRONG&gt;&amp;nbsp;(3+2+2)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;same_count=7&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;not_same_count:&lt;/STRONG&gt;The number of variables that do not repeat more than once&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;for id = 1, &amp;nbsp;Repeated 3&amp;nbsp;to &lt;STRONG&gt;1&lt;/STRONG&gt;&amp;nbsp;times,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Repeated a&amp;nbsp;to &lt;STRONG&gt;1&lt;/STRONG&gt;&amp;nbsp;times,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Repeated b&amp;nbsp;to &lt;STRONG&gt;1&lt;/STRONG&gt;&amp;nbsp;times,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Repeated 4&amp;nbsp;to &lt;STRONG&gt;1&lt;/STRONG&gt;&amp;nbsp;times,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Repeated x&amp;nbsp;to &lt;STRONG&gt;1&lt;/STRONG&gt;&amp;nbsp;times&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and&amp;nbsp;Their &lt;STRONG&gt;sum is&amp;nbsp;5&lt;/STRONG&gt;&amp;nbsp;(1+1+1+1+1)&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;not_same_count=5&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope,It is more descriptive.&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 17:34:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-multiple-columns-and-concat/m-p/352249#M82082</guid>
      <dc:creator>erdem_ustun</dc:creator>
      <dc:date>2017-04-21T17:34:20Z</dc:date>
    </item>
  </channel>
</rss>

