<?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: Equality Comparison on User Defined Formats in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591660#M15242</link>
    <description>&lt;P&gt;The first character of "5000-10000" is "5", which comes later in the collating sequence than the first character of "10000-25000" ("1").&lt;/P&gt;
&lt;P&gt;So "5000-10000" is "greater" than "10000-25000", when compared as strings.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Sep 2019 18:33:18 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-09-25T18:33:18Z</dc:date>
    <item>
      <title>Equality Comparison on User Defined Formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591642#M15239</link>
      <description>&lt;P&gt;Please run the below code and check for dataset &lt;U&gt;&lt;STRONG&gt;have2&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Why do I get value of flag as "2&amp;lt;1" when all values in nos2 is &amp;gt; nos1?&lt;/P&gt;&lt;P&gt;What am I missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FORMAT;
VALUE rvsd_format
	5000-10000="5000-10000"
	10000-25000="10000-25000"
;
run;

data have;
input nos1 nos2;
datalines ;	
9544.59 10605.10
8588.00 10781.20
9029.48 11061.31
9831.00 10158.70
9454.00 13380.18
9504.00 15888.00
8400.00 12728.80
6672.00 16516.00
7595.12 14062.24
9951.13 10780.39
;
run;
data have2;
set have;
fmt_nos1=put(nos1,rvsd_format.);
fmt_nos2=put(nos2,rvsd_format.);
if fmt_nos2=fmt_nos1 then flag="Equal";
else if fmt_nos2&amp;gt;fmt_nos1 then flag="2&amp;gt;1";
else flag="2&amp;lt;1";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Sep 2019 18:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591642#M15239</guid>
      <dc:creator>david27</dc:creator>
      <dc:date>2019-09-25T18:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Equality Comparison on User Defined Formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591648#M15240</link>
      <description>&lt;P&gt;Here you are comparing the the character variables because of which it is taking the last else condition&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;flag&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;"2&amp;lt;1"&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;You need to compare the numeric variables &lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 18:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591648#M15240</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-25T18:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Equality Comparison on User Defined Formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591654#M15241</link>
      <description>&lt;P&gt;Please try the below code where I used the invalue for creating the informat as 1 and 2 and now you will get the expected result in the flag variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FORMAT;
inVALUE rvsd_format
	5000-10000=1
	10000-25000=2
;
run;

data have;
input nos1 nos2;
datalines ;	
9544.59 10605.10
8588.00 10781.20
9029.48 11061.31
9831.00 10158.70
9454.00 13380.18
9504.00 15888.00
8400.00 12728.80
6672.00 16516.00
7595.12 14062.24
9951.13 10780.39
;
run;

data have2;
set have;
fmt_nos1=input(nos1,rvsd_format.);
fmt_nos2=input(nos2,rvsd_format.);
if fmt_nos2=fmt_nos1 then flag="Equal";
else if fmt_nos2&amp;gt;fmt_nos1 then flag="2&amp;gt;1";
else flag="2&amp;lt;1";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Sep 2019 18:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591654#M15241</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-09-25T18:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Equality Comparison on User Defined Formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591660#M15242</link>
      <description>&lt;P&gt;The first character of "5000-10000" is "5", which comes later in the collating sequence than the first character of "10000-25000" ("1").&lt;/P&gt;
&lt;P&gt;So "5000-10000" is "greater" than "10000-25000", when compared as strings.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 18:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591660#M15242</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-25T18:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Equality Comparison on User Defined Formats</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591682#M15248</link>
      <description>&lt;P&gt;Not sure why are are comparing the strings generated by the format instead of the actual numbers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why not just make sure the strings are formatted so they can be compared?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;VALUE rvsd_format
   5000-10000="05000-10000"
  10000-25000="10000-25000"
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Sep 2019 19:45:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Equality-Comparison-on-User-Defined-Formats/m-p/591682#M15248</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-09-25T19:45:49Z</dc:date>
    </item>
  </channel>
</rss>

