<?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: Comparing variables in a table and eliminating odds in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718560#M222405</link>
    <description>&lt;P&gt;Similar method. Keep the first value in a retained variable, and compare to the others.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by pat_id;
retain _date flag;
if first.pat_id
then do;
  _date = date;
  flag = 0;
end;
else if date ne _date then flag = 1;
if last.pat_id; /* if you only want one observation per id */
drop _date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 11 Feb 2021 12:35:23 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-02-11T12:35:23Z</dc:date>
    <item>
      <title>Comparing variables in a table and eliminating odds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718540#M222396</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;
&lt;P&gt;I have a table containing birthdays for a patients. Because this table is the combination of more tables, I have more columns with birthday. for example diagnosis bithday, therapie birthday, follow-up birthday and so on (up to about 8 birthdays)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wish to compare these birthdays. If about let say seven birthdays are the same and only one is different then I will like to mark than column as maybe 1 and probably eliminate the odd in the next step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set test1;
if column1 ^= column2 and column2 ^= column3 and column3^= column4 &lt;BR /&gt;and column4 ^= column5 and column5 ^= column6 and column6 ^= column7 &lt;BR /&gt;and column7 ^= column8 then col_not_equal =1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;using&amp;nbsp; a code like this is not elegant. Is there an elegant way to do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;best regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 11:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718540#M222396</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-02-11T11:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variables in a table and eliminating odds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718544#M222398</link>
      <description>&lt;P&gt;First of all, your code will only work if NO two dates are equal, because you used AND instead of OR.&lt;/P&gt;
&lt;P&gt;I would use an array over date columns 2 to n, and run a do loop over it and compare it to the first:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array dates {*} column2-column7;
flag = 0;
do i = 1 to dim(dates);
  if dates{i} ne column1 then flag = 1;
end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2021 11:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718544#M222398</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-11T11:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variables in a table and eliminating odds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718546#M222399</link>
      <description>&lt;P&gt;In your problem, does the year of the birthdays have to match all the other years, or do you want just the month-day (but not year) to match across all the birthdays?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 11:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718546#M222399</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-11T11:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variables in a table and eliminating odds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718547#M222400</link>
      <description>&lt;P&gt;actually all, day, month and year&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 12:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718547#M222400</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-02-11T12:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variables in a table and eliminating odds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718549#M222401</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;, thanks for the code. I will try thank now and see</description>
      <pubDate>Thu, 11 Feb 2021 12:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718549#M222401</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-02-11T12:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variables in a table and eliminating odds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718558#M222403</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;: is it also possible to compare data in rows with each other using this method &lt;BR /&gt;pat_id&amp;nbsp; fol_up_id&amp;nbsp; birthday&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&amp;nbsp; 10/01/67&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; 10/01&lt;SPAN style="font-family: inherit;"&gt;/67&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp;11/10/76&lt;BR /&gt;1&amp;nbsp; &amp;nbsp; 11&amp;nbsp; &amp;nbsp; 10/01/67&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2021 12:31:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718558#M222403</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-02-11T12:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variables in a table and eliminating odds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718559#M222404</link>
      <description>&lt;P&gt;This is a use case for MIN and MAX functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If all the birthdate vars are column1,column2, ... (i.e. the birthdates, and only the birthdates, all begin with "column"), then:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set test1;
  if min(of column:)^=max(of column:) then flag=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if the varnames are not so neatly named, then:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  set test1;
  if min(bdatex, datebd, otherdate, ...) ^= max(bdatex, datebd, otherdate,...) then flag=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2021 12:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718559#M222404</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-02-11T12:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variables in a table and eliminating odds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718560#M222405</link>
      <description>&lt;P&gt;Similar method. Keep the first value in a retained variable, and compare to the others.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by pat_id;
retain _date flag;
if first.pat_id
then do;
  _date = date;
  flag = 0;
end;
else if date ne _date then flag = 1;
if last.pat_id; /* if you only want one observation per id */
drop _date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2021 12:35:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718560#M222405</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-11T12:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing variables in a table and eliminating odds</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718561#M222406</link>
      <description>Thanks a lot for that</description>
      <pubDate>Thu, 11 Feb 2021 12:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparing-variables-in-a-table-and-eliminating-odds/m-p/718561#M222406</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-02-11T12:42:04Z</dc:date>
    </item>
  </channel>
</rss>

