<?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 Min and Max Function: Is it mandatory to use a leading „of“ when using min/max with variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Min-and-Max-Function-Is-it-mandatory-to-use-a-leading-of-when/m-p/85472#M289002</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My questions applies to the min and max function. In the following I will use the min function for simplification.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The help function on min says „&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;The argument list can consist of a variable list, which is preceded by OF.”&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;I was wondering whether it is mandatory to use the “of”.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;In fact I have been using the min function for a long time never being aware of this. So far I am neither aware that leaving out the min caused problems.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;Recently a colleague of mine pointed out to me that he has seen examples where this can cause problems (however, he cannot recall the specific case). Thus he suggested to always use “OF”.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;Now this question came up since we have quite some programs that use min in dozens of places and we want to find out whether we should amend the programs or not.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;In fact this leads to a few follow up questions. Usually I make use of variable operations as well as the usage of macro variables in min. To give you an example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;%let mvar=2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;data&amp;nbsp; _&lt;EM&gt;null&lt;/EM&gt;_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;a=9;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;b=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;c=min(a,b,a*&amp;amp;mvar.,a*b+b,a*99,b/&amp;amp;mvar.+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;put c;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;So my question is whether using min in this way will always yield the result I had in mind (which is canonical).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;It seems to me that if I was to meticulously apply the min function as described in the help function, I would need to define additional variables. For example already a simple statement such as “c=min(of a*b,b)” results in an error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;Has anyone encountered unexpected behaviour with the min function by not using the "of" (or because of other reasons) like my colleague has?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;Bernhard&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Mar 2013 08:37:51 GMT</pubDate>
    <dc:creator>bernhard</dc:creator>
    <dc:date>2013-03-22T08:37:51Z</dc:date>
    <item>
      <title>Min and Max Function: Is it mandatory to use a leading „of“ when using min/max with variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Min-and-Max-Function-Is-it-mandatory-to-use-a-leading-of-when/m-p/85472#M289002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My questions applies to the min and max function. In the following I will use the min function for simplification.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The help function on min says „&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;The argument list can consist of a variable list, which is preceded by OF.”&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;I was wondering whether it is mandatory to use the “of”.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;In fact I have been using the min function for a long time never being aware of this. So far I am neither aware that leaving out the min caused problems.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;Recently a colleague of mine pointed out to me that he has seen examples where this can cause problems (however, he cannot recall the specific case). Thus he suggested to always use “OF”.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;Now this question came up since we have quite some programs that use min in dozens of places and we want to find out whether we should amend the programs or not.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;In fact this leads to a few follow up questions. Usually I make use of variable operations as well as the usage of macro variables in min. To give you an example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;%let mvar=2;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;data&amp;nbsp; _&lt;EM&gt;null&lt;/EM&gt;_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;a=9;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;b=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;c=min(a,b,a*&amp;amp;mvar.,a*b+b,a*99,b/&amp;amp;mvar.+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;put c;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;So my question is whether using min in this way will always yield the result I had in mind (which is canonical).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;It seems to me that if I was to meticulously apply the min function as described in the help function, I would need to define additional variables. For example already a simple statement such as “c=min(of a*b,b)” results in an error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;Has anyone encountered unexpected behaviour with the min function by not using the "of" (or because of other reasons) like my colleague has?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Arial','sans-serif'; color: black;"&gt;Bernhard&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 08:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Min-and-Max-Function-Is-it-mandatory-to-use-a-leading-of-when/m-p/85472#M289002</guid>
      <dc:creator>bernhard</dc:creator>
      <dc:date>2013-03-22T08:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Min and Max Function: Is it mandatory to use a leading „of“ when using min/max with variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Min-and-Max-Function-Is-it-mandatory-to-use-a-leading-of-when/m-p/85473#M289003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is my understanding that OF is only required when the list of parameters is a range of variables, eg min (OF var1-var3).&amp;nbsp; Prefacing a delimited list of parameters, as in your example, should have no effect because in this instance the OF wold apply only to the first (single) parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 09:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Min-and-Max-Function-Is-it-mandatory-to-use-a-leading-of-when/m-p/85473#M289003</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2013-03-22T09:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Min and Max Function: Is it mandatory to use a leading „of“ when using min/max with variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Min-and-Max-Function-Is-it-mandatory-to-use-a-leading-of-when/m-p/85474#M289004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Each comma separated argument can be an expression or a variable list as specified by the word OF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;min(1+2,var1-4,var1-var4,of var1-var4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The third argument is var1 minus var4&lt;/P&gt;&lt;P&gt;The fourth is OF the variable list.&lt;/P&gt;&lt;P&gt;You can see how omitting the word OF when a variable list intended could be a problem.&lt;/P&gt;&lt;P&gt;You could use&amp;nbsp; "of array reference" which might help to prevent the var1 minus var4 ommitted OF problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;28&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;29&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array var[&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;] (&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;:&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;30&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = min(&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;+&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,var1-&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,var1-var4,of var1-var4,&lt;STRONG&gt;of var&lt;/STRONG&gt;&lt;LI&gt;&lt;STRONG&gt;);&lt;/STRONG&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;31&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put x=;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;32&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;x&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=-&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 11:25:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Min-and-Max-Function-Is-it-mandatory-to-use-a-leading-of-when/m-p/85474#M289004</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-03-22T11:25:28Z</dc:date>
    </item>
  </channel>
</rss>

