<?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: How can I flag multiple variable having same value for a particular subject? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673006#M202358</link>
    <description />
    <pubDate>Thu, 03 Sep 2020 21:52:08 GMT</pubDate>
    <dc:creator>nirsan</dc:creator>
    <dc:date>2020-09-03T21:52:08Z</dc:date>
    <item>
      <title>How can I flag multiple variable having same value for a particular subject?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673003#M202355</link>
      <description />
      <pubDate>Thu, 03 Sep 2020 21:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673003#M202355</guid>
      <dc:creator>nirsan</dc:creator>
      <dc:date>2020-09-03T21:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I flag multiple variable having same value for a particular subject?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673005#M202357</link>
      <description>&lt;OL&gt;
&lt;LI&gt;What do you want the output to look like?&amp;nbsp; Will you test for all duplicates within an ID, or just a dummy indicating duplicates have been found?&amp;nbsp; How do you want the test results presented?&lt;/LI&gt;
&lt;LI&gt;Do you want tested code?&amp;nbsp; Is so, please provide a sampe dataset in the form of a DATA step.&amp;nbsp; Help us help you.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 00:10:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673005#M202357</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-07-29T00:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I flag multiple variable having same value for a particular subject?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673006#M202358</link>
      <description />
      <pubDate>Thu, 03 Sep 2020 21:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673006#M202358</guid>
      <dc:creator>nirsan</dc:creator>
      <dc:date>2020-09-03T21:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: How can I flag multiple variable having same value for a particular subject?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673008#M202360</link>
      <description>&lt;P&gt;For each observation, you could successively compare the largest HLTH code to the 2nd largest, then the 2nd largest to the 3rd largest until you either exhaust all the non-missing values (so flag would be 0), or you find a duplicate (flag=1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do that you can use the LARGEST function and the LAG function, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (drop=_:);
  set have;
  flag=0;
  do _L=1 to n(of hlth:) while (flag=0);
    _x=largest(_L,of hlth:);
    if _L&amp;gt;1 and _x=lag(_x) then flag=1;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm not going to test this on your data -&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 00:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673008#M202360</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-07-29T00:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: How can I flag multiple variable having same value for a particular subject?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673013#M202365</link>
      <description>&lt;P&gt;As long as you copy the data to another data set (because we're going to change data values), it should be easy enough.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Put the variables into an array, then use call sortc to change the order of the variables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then move through the array and compare whether two consecutive values are identical (being careful not to take two consecutive missing values).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if you need help with this.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 01:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673013#M202365</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-07-29T01:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I flag multiple variable having same value for a particular subject?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673026#M202373</link>
      <description>&lt;P&gt;Here's a more complete version.&amp;nbsp; It assumes your variables are character.&amp;nbsp; If they are numeric, you would need to switch from SORTC to SORTN.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=id);
set have;
array hlth {20};
call sortc (of hlth{*});
do _n_=1 to 19 until (flag=1);
   if not missing (hlth{_n_}) and hlth{_n_} = hlth{_n_+1} then flag=1;
end;&lt;BR /&gt;if flag=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This version keeps just the ID.&amp;nbsp; You would have to go back to the original data to check why these IDs are flagged.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jul 2020 02:51:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-flag-multiple-variable-having-same-value-for-a/m-p/673026#M202373</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-07-29T02:51:05Z</dc:date>
    </item>
  </channel>
</rss>

