<?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: Find Outliers and Matches in dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763950#M241951</link>
    <description>&lt;P&gt;This way isn't terribly concise. Someone may have a better method, but it seems to match your output.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value $matches
		"1,1" = "Found"
		"0,0" = "NoMatch"
		"1,0" = "Missing"
		"0,1" = "NoMatch";
run;

data want (drop = a: output_flag i);
	merge 	have (in = a where = (yr = 2019) rename = (a1 = a1_19 a2 = a2_19 a3 = a3_19))
		  	have (in = b where = (yr = 2020) rename = (a1 = a1_20 a2 = a2_20 a3 = a3_20));
	by		member;

			_a1_1920 = put(catx(",", a1_19, a1_20), $matches.);
			_a2_1920 = put(catx(",", a2_19, a2_20), $matches.);
			_a3_1920 = put(catx(",", a3_19, a3_20), $matches.);

	array checkmiss [*] _a:;

	do i = 1 to dim(checkmiss);
		if checkmiss[i] = "Missing" then output_flag = "1";
	end;

	if output_flag = "1" then output;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs Member YR _a1_1920 _a2_1920 _a3_1920 
1 124 2020 Missing Found NoMatch 
2 126 2020 NoMatch Missing Found 
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Aug 2021 18:26:43 GMT</pubDate>
    <dc:creator>maguiremq</dc:creator>
    <dc:date>2021-08-25T18:26:43Z</dc:date>
    <item>
      <title>Find Outliers and Matches in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763920#M241940</link>
      <description>&lt;P&gt;I have a dataset where i'm trying to determine fallout/ outliers from a previous year. Here is an example of the table below:&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 240pt;" border="0" width="320" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" class="xl65" style="height: 15.0pt; width: 48pt;"&gt;Member&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-left: none; width: 48pt;"&gt;YR&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-left: none; width: 48pt;"&gt;A1&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-left: none; width: 48pt;"&gt;A2&lt;/TD&gt;
&lt;TD width="64" class="xl65" style="border-left: none; width: 48pt;"&gt;A3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;123&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2019&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;123&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2020&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;124&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2019&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;124&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2020&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;125&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2019&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;125&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2020&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;126&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2019&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" align="right" class="xl65" style="height: 15.0pt; border-top: none;"&gt;126&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2020&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;The A1-A3 are hierarchy based, A1 being most important and A3 being least. I'm trying to identify members and their corresponding A1 - A3 that didn't match from the previous year. So an expected output would be something like below:&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="345"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;Member&lt;/TD&gt;
&lt;TD width="64"&gt;YR&lt;/TD&gt;
&lt;TD width="89"&gt;A1&lt;/TD&gt;
&lt;TD width="64"&gt;A2&lt;/TD&gt;
&lt;TD width="64"&gt;A3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;124&lt;/TD&gt;
&lt;TD&gt;2020&lt;/TD&gt;
&lt;TD&gt;Missing&lt;/TD&gt;
&lt;TD&gt;Found&lt;/TD&gt;
&lt;TD&gt;NoMatch&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;126&lt;/TD&gt;
&lt;TD&gt;2020&lt;/TD&gt;
&lt;TD&gt;NoMatch&lt;/TD&gt;
&lt;TD&gt;Missing&lt;/TD&gt;
&lt;TD&gt;Found&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The goal is to find the A1-A3 variable assigned to a member that's missing, matched or has No Match on the previous year. In this case I'm looking at 2019 and matching it to 2020, so I only need 2020 rows/columns back.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've tried building arrays and transposing the data with incld and excld columns for each year to find the missing or Nomatches and i cant seem to get the desired output. Any help would be appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 17:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763920#M241940</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2021-08-25T17:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Find Outliers and Matches in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763922#M241941</link>
      <description>&lt;P&gt;Please explain in more detail the criteria that lead to "Missing","Found" or "NoMatch"&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 17:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763922#M241941</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-25T17:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Find Outliers and Matches in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763927#M241942</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; in this case it would be Member= 124 had an A1= 1 in 2019 but an A1=0 in 2020 this qualifies as 'Missing', A2=1 in 2019 and A2=1 in 2020 so this qualifies as 'Match' and A3=0 for 2019 and A3=0 for 2020 so this qualifies as 'NoMatch'. &lt;BR /&gt;&lt;BR /&gt;So if a member had an A1 - A3 populated in 2019 and its not populated in 2020 this would be a 'Missing'. If a Member had an A1-A3 populated in 2019 and 2020 then this is a Match and if a Member had an A1-A3 not populated for 2019 and 2020 this is a 'Nomatch'.</description>
      <pubDate>Wed, 25 Aug 2021 17:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763927#M241942</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2021-08-25T17:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Find Outliers and Matches in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763928#M241943</link>
      <description>&lt;P&gt;Okay, thanks, but you also said&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The A1-A3 are hierarchy based, A1 being most important and A3 being least.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I don't see how that works into the logic here.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 17:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763928#M241943</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-25T17:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Find Outliers and Matches in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763929#M241944</link>
      <description>So for that I'm only concerned where if Missing is higher in the hierarchy. Meaning, if an A3 was populated in 2019 and not populated in 2020 but an A2 was populated in 2020 and not in 2019 I would exclude this/ or not look at this record. Hope that makes sense...</description>
      <pubDate>Wed, 25 Aug 2021 17:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763929#M241944</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2021-08-25T17:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Find Outliers and Matches in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763943#M241948</link>
      <description>&lt;P&gt;Where does 'found' come in?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: nevermind, I see.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 18:19:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763943#M241948</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-08-25T18:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Find Outliers and Matches in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763950#M241951</link>
      <description>&lt;P&gt;This way isn't terribly concise. Someone may have a better method, but it seems to match your output.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value $matches
		"1,1" = "Found"
		"0,0" = "NoMatch"
		"1,0" = "Missing"
		"0,1" = "NoMatch";
run;

data want (drop = a: output_flag i);
	merge 	have (in = a where = (yr = 2019) rename = (a1 = a1_19 a2 = a2_19 a3 = a3_19))
		  	have (in = b where = (yr = 2020) rename = (a1 = a1_20 a2 = a2_20 a3 = a3_20));
	by		member;

			_a1_1920 = put(catx(",", a1_19, a1_20), $matches.);
			_a2_1920 = put(catx(",", a2_19, a2_20), $matches.);
			_a3_1920 = put(catx(",", a3_19, a3_20), $matches.);

	array checkmiss [*] _a:;

	do i = 1 to dim(checkmiss);
		if checkmiss[i] = "Missing" then output_flag = "1";
	end;

	if output_flag = "1" then output;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Obs Member YR _a1_1920 _a2_1920 _a3_1920 
1 124 2020 Missing Found NoMatch 
2 126 2020 NoMatch Missing Found 
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 18:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763950#M241951</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-08-25T18:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Find Outliers and Matches in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763953#M241952</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines;
  input member year A1 - A3;
datalines;
123 2019 1 0 1
123 2020 1 0 1
124 2019 1 1 0
124 2020 0 1 0
125 2019 0 1 1
125 2020 1 1 1
126 2019 0 1 1
126 2020 0 0 1
;;;;;;
run;

proc format;
  value FMnM /*Found-Missing-noMatch*/
  1="Missing"	/*1,0*/
  2="New?"   /*0,1*/
  3="Found"  /*1,1*/
  0="NoMatch" /*0,0*/
  ;
run;

proc sql;
  create table want as
    select this.member, this.year,
           this.A1*2+last.A1 format=FMnM. as A1,
           this.A2*2+last.A2 format=FMnM. as A2,
           this.A3*2+last.A3 format=FMnM. as A3
    from have as this, have as last
    where this.year=last.year+1 
      AND this.Member=last.member;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 18:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/763953#M241952</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-08-25T18:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Find Outliers and Matches in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/764149#M242019</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281770"&gt;@maguiremq&lt;/a&gt;&amp;nbsp;this worked quite well. Thank you for this. I modified it slightly to include hierarchy. Thank you very much. Both you and another use provided solutions.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 11:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/764149#M242019</guid>
      <dc:creator>bknitch</dc:creator>
      <dc:date>2021-08-26T11:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Find Outliers and Matches in dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/764162#M242024</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192500"&gt;@bknitch&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;So for that I'm only concerned where if Missing is higher in the hierarchy. Meaning, if an A3 was populated in 2019 and not populated in 2020 but an A2 was populated in 2020 and not in 2019 I would exclude this/ or not look at this record. Hope that makes sense...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sorry, no I still don't understand. What does "exclude" mean in the context of your earlier description of how to assign the "Missing" "Found" "NoMatch" to each cell?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I think we have gone far enough down this path. If the code provided so far meets your need, fine, problem solved. If not, I am asking you to re-write the requirements from scratch, to address all of these issues, so that the explanation is clear and in one description of the logic, so we don't have to scroll up and down and re-read earlier comments to put it all together and understand.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 12:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-Outliers-and-Matches-in-dataset/m-p/764162#M242024</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-26T12:42:54Z</dc:date>
    </item>
  </channel>
</rss>

