<?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: Monotonic() function in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4730#M1922</link>
    <description>As Ian Whitlock once said, "You are probably getting something that you didn't expect because you didn't know what your program was telling the computer to do."&lt;BR /&gt;
&lt;BR /&gt;
Using a data set that everyone has:&lt;BR /&gt;
&lt;BR /&gt;
=====&lt;BR /&gt;
proc sort data=sashelp.class out=top10 (where=(monotonic() le 10));&lt;BR /&gt;
   by age name;&lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   create table top10a as  &lt;BR /&gt;
      select   *  &lt;BR /&gt;
      from     sashelp.class&lt;BR /&gt;
      where    monotonic() le 10&lt;BR /&gt;
      order    by age, name;&lt;BR /&gt;
quit;&lt;BR /&gt;
====&lt;BR /&gt;
&lt;BR /&gt;
The two output data sets are different because they're asking for different things.  The data step equivalent of the SQL code is:&lt;BR /&gt;
&lt;BR /&gt;
=====&lt;BR /&gt;
proc sort data=sashelp.class (where=(monotonic() le 10)) out=top10b;&lt;BR /&gt;
   by age name;&lt;BR /&gt;
run;&lt;BR /&gt;
=====&lt;BR /&gt;
&lt;BR /&gt;
Comparisons:&lt;BR /&gt;
&lt;BR /&gt;
=====&lt;BR /&gt;
64   proc compare base=top10 compare=top10b warning;&lt;BR /&gt;
65   run;&lt;BR /&gt;
&lt;BR /&gt;
WARNING: Values of the following 5 variables compare unequal: Name Sex Age Height Weight&lt;BR /&gt;
WARNING: The data sets WORK.TOP10 and WORK.TOP10B contain unequal values.&lt;BR /&gt;
NOTE: There were 10 observations read from the data set WORK.TOP10.&lt;BR /&gt;
NOTE: There were 10 observations read from the data set WORK.TOP10B.&lt;BR /&gt;
NOTE: PROCEDURE COMPARE used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
66   proc compare base=top10a compare=top10b warning;&lt;BR /&gt;
67   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 10 observations read from the data set WORK.TOP10A.&lt;BR /&gt;
NOTE: There were 10 observations read from the data set WORK.TOP10B.&lt;BR /&gt;
NOTE: PROCEDURE COMPARE used (Total process time):&lt;BR /&gt;
      real time           0.03 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
=====</description>
    <pubDate>Mon, 17 Sep 2007 19:13:27 GMT</pubDate>
    <dc:creator>JackHamilton</dc:creator>
    <dc:date>2007-09-17T19:13:27Z</dc:date>
    <item>
      <title>Monotonic() function</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4725#M1917</link>
      <description>I found the following code in an old program at my shop that uses monotonic() in a where statement. I know that monotonic is a SQL function that's not supported but here it is used in a proc sort. &lt;BR /&gt;
&lt;BR /&gt;
Can someone please tell me how this works in the following context? The code returns the 10 highest scores. Thanks.&lt;BR /&gt;
&lt;BR /&gt;
proc sort data = mydata out=top10(where=(monotonic() le 10));&lt;BR /&gt;
   by descending start_dt;&lt;BR /&gt;
run;</description>
      <pubDate>Sun, 16 Sep 2007 00:30:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4725#M1917</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-09-16T00:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: Monotonic() function</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4726#M1918</link>
      <description>Hi:&lt;BR /&gt;
  You might try Tech Support for the definitive answer. This note says it's not supported and, if used, might give incorrect results,&lt;BR /&gt;
 &lt;A href="http://support.sas.com/techsup/unotes/SN/015/015138.html" target="_blank"&gt;http://support.sas.com/techsup/unotes/SN/015/015138.html&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Yet, these papers all mention it as a function that "sort of" works like _N_:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi29/040-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/040-29.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi31/250-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/250-31.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.lexjansen.com/pharmasug/2006/tutorials/tu01.pdf" target="_blank"&gt;http://www.lexjansen.com/pharmasug/2006/tutorials/tu01.pdf&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Sun, 16 Sep 2007 04:14:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4726#M1918</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-09-16T04:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Monotonic() function</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4727#M1919</link>
      <description>Thanks Cynthia.&lt;BR /&gt;
&lt;BR /&gt;
The reason I posted my question was the use of monotonic in a where statement &lt;I&gt;outside&lt;/I&gt; of SQL. I was thinking maybe this is a different function because it is not being used in SQL.&lt;BR /&gt;
&lt;BR /&gt;
dan

Message was edited by: danthesasman</description>
      <pubDate>Mon, 17 Sep 2007 14:35:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4727#M1919</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-09-17T14:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Monotonic() function</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4728#M1920</link>
      <description>Ah, I understand. I believe that there's only ONE where statement/clause processor and it lives in the PROC SQL routine. SAS did not have WHERE before PROC SQL. Tech Support would know for sure. I know that the WHERE statement in a SAS proc works the same way as a WHERE in SQL -- the type (character and numeric) have to agree. So, for example, in an IF statement, I can say&lt;BR /&gt;
[pre]&lt;BR /&gt;
if numvar = '1';&lt;BR /&gt;
[/pre]&lt;BR /&gt;
and the IF statement will very nicely do a conversion for me, but a WHERE statement:&lt;BR /&gt;
[pre]&lt;BR /&gt;
where numvar = '1';&lt;BR /&gt;
[/pre]&lt;BR /&gt;
gets you an error message. Which all indicates to me that ANYTHING you can do in WHERE (because it "belongs" to SQL) will work.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 17 Sep 2007 15:30:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4728#M1920</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-09-17T15:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Monotonic() function</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4729#M1921</link>
      <description>Thanks, I wasn't aware that WHERE was a part of SQL.&lt;BR /&gt;
&lt;BR /&gt;
The funny thing is that I ran the code 2 different ways. The first with MONTONIC in SQL and the second time using WHERE in a PROC SORT. I got the correct results with the SORT but not with SQL.&lt;BR /&gt;
&lt;BR /&gt;
dan</description>
      <pubDate>Mon, 17 Sep 2007 17:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4729#M1921</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-09-17T17:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Monotonic() function</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4730#M1922</link>
      <description>As Ian Whitlock once said, "You are probably getting something that you didn't expect because you didn't know what your program was telling the computer to do."&lt;BR /&gt;
&lt;BR /&gt;
Using a data set that everyone has:&lt;BR /&gt;
&lt;BR /&gt;
=====&lt;BR /&gt;
proc sort data=sashelp.class out=top10 (where=(monotonic() le 10));&lt;BR /&gt;
   by age name;&lt;BR /&gt;
run; &lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
   create table top10a as  &lt;BR /&gt;
      select   *  &lt;BR /&gt;
      from     sashelp.class&lt;BR /&gt;
      where    monotonic() le 10&lt;BR /&gt;
      order    by age, name;&lt;BR /&gt;
quit;&lt;BR /&gt;
====&lt;BR /&gt;
&lt;BR /&gt;
The two output data sets are different because they're asking for different things.  The data step equivalent of the SQL code is:&lt;BR /&gt;
&lt;BR /&gt;
=====&lt;BR /&gt;
proc sort data=sashelp.class (where=(monotonic() le 10)) out=top10b;&lt;BR /&gt;
   by age name;&lt;BR /&gt;
run;&lt;BR /&gt;
=====&lt;BR /&gt;
&lt;BR /&gt;
Comparisons:&lt;BR /&gt;
&lt;BR /&gt;
=====&lt;BR /&gt;
64   proc compare base=top10 compare=top10b warning;&lt;BR /&gt;
65   run;&lt;BR /&gt;
&lt;BR /&gt;
WARNING: Values of the following 5 variables compare unequal: Name Sex Age Height Weight&lt;BR /&gt;
WARNING: The data sets WORK.TOP10 and WORK.TOP10B contain unequal values.&lt;BR /&gt;
NOTE: There were 10 observations read from the data set WORK.TOP10.&lt;BR /&gt;
NOTE: There were 10 observations read from the data set WORK.TOP10B.&lt;BR /&gt;
NOTE: PROCEDURE COMPARE used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
66   proc compare base=top10a compare=top10b warning;&lt;BR /&gt;
67   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 10 observations read from the data set WORK.TOP10A.&lt;BR /&gt;
NOTE: There were 10 observations read from the data set WORK.TOP10B.&lt;BR /&gt;
NOTE: PROCEDURE COMPARE used (Total process time):&lt;BR /&gt;
      real time           0.03 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
=====</description>
      <pubDate>Mon, 17 Sep 2007 19:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Monotonic-function/m-p/4730#M1922</guid>
      <dc:creator>JackHamilton</dc:creator>
      <dc:date>2007-09-17T19:13:27Z</dc:date>
    </item>
  </channel>
</rss>

