<?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 compare values of 3 or more numeric variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/compare-values-of-3-or-more-numeric-variables/m-p/775750#M246604</link>
    <description>&lt;P&gt;Is there a way to check if the values&amp;nbsp;of 3 or more numeric variables are all equal or not?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	var1=0;var2=0;var3=0;output;
	var1=1;var2=1;var3=1;output;
	var1=1;var2=1;var3=0;output;
	var1=1;var2=1;var3=.;output;
	var1=1;var2=.;var3=.;output;
	var1=.;var2=.;var3=.;output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="tinyMceEditorrommel_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rommel_1-1634848162214.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64939i511DA26C4FB7A369/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rommel_1-1634848162214.png" alt="rommel_1-1634848162214.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Oct 2021 20:37:04 GMT</pubDate>
    <dc:creator>dataMart87</dc:creator>
    <dc:date>2021-10-21T20:37:04Z</dc:date>
    <item>
      <title>compare values of 3 or more numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-values-of-3-or-more-numeric-variables/m-p/775750#M246604</link>
      <description>&lt;P&gt;Is there a way to check if the values&amp;nbsp;of 3 or more numeric variables are all equal or not?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	var1=0;var2=0;var3=0;output;
	var1=1;var2=1;var3=1;output;
	var1=1;var2=1;var3=0;output;
	var1=1;var2=1;var3=.;output;
	var1=1;var2=.;var3=.;output;
	var1=.;var2=.;var3=.;output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="tinyMceEditorrommel_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rommel_1-1634848162214.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64939i511DA26C4FB7A369/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rommel_1-1634848162214.png" alt="rommel_1-1634848162214.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 20:37:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-values-of-3-or-more-numeric-variables/m-p/775750#M246604</guid>
      <dc:creator>dataMart87</dc:creator>
      <dc:date>2021-10-21T20:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: compare values of 3 or more numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-values-of-3-or-more-numeric-variables/m-p/775754#M246608</link>
      <description>If the RANGE=0 then all values are the same, range is max of series minus the minimum of the series. &lt;BR /&gt;&lt;BR /&gt;if range(of var1-var3)=0 then result='eq';</description>
      <pubDate>Thu, 21 Oct 2021 20:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-values-of-3-or-more-numeric-variables/m-p/775754#M246608</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-21T20:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: compare values of 3 or more numeric variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-values-of-3-or-more-numeric-variables/m-p/775764#M246618</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/2725"&gt;@dataMart87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there a way to check if the values&amp;nbsp;of 3 or more numeric variables are all equal or not?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	var1=0;var2=0;var3=0;output;
	var1=1;var2=1;var3=1;output;
	var1=1;var2=1;var3=0;output;
	var1=1;var2=1;var3=.;output;
	var1=1;var2=.;var3=.;output;
	var1=.;var2=.;var3=.;output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV id="tinyMceEditorrommel_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rommel_1-1634848162214.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64939i511DA26C4FB7A369/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rommel_1-1634848162214.png" alt="rommel_1-1634848162214.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What is "am" supposed to represent?&lt;/P&gt;
&lt;P&gt;I really dislike character values for yes/no equal/not equal true/false.&lt;/P&gt;
&lt;P&gt;SAS will report 1 as "true/yes" and 0 for "false/no" from comparisons.&lt;/P&gt;
&lt;P&gt;Assuming that that you "am" means "no values to compare" this is my approach.The test of NMISS is looking to see if all the values are missing and if so overwrites the normal (yes all the values are the same as all missing are the same value) 1 with a missing value.&lt;/P&gt;
&lt;P&gt;Note the much simpler data step for getting the values into the data set.&lt;/P&gt;
&lt;PRE&gt;data have;
   input var1 var2 var3;
   eq = (var1=var2=var3);
   if nmiss(of var:) = 3 then eq=.;
datalines;
0 0 0 
1 1 1 
1 1 0 
1 1 . 
1 . . 
. . . 
run;&lt;/PRE&gt;
&lt;P&gt;If I really wanted to see "eq" "ne" or "am" I would write a custom format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint on some reasons to use 1/0 coding scheme.&lt;/P&gt;
&lt;P&gt;Sum of the variable EQ is the number of 1's (or values all equal)&lt;/P&gt;
&lt;P&gt;Mean of EQ is the percent of 1's &lt;STRONG&gt;when any values are present&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Max of Eq, if equal to 1 means that at least one record has all equal&lt;/P&gt;
&lt;P&gt;Min of Eq if equal to 1 means that all records with at least one non-missing value are all the same; if zero than at least one record has different values; if missing means that all the values for all the records were missing.&lt;/P&gt;
&lt;P&gt;Nmiss of Eq would tell you how many records have no values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It takes very little code to get that information:&lt;/P&gt;
&lt;PRE&gt;Proc means data= have min max mean sum nmiss;
   var eq;
run;&lt;/PRE&gt;
&lt;P&gt;Try getting the same information quickly with character values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 21:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-values-of-3-or-more-numeric-variables/m-p/775764#M246618</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-21T21:21:28Z</dc:date>
    </item>
  </channel>
</rss>

