<?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: Is it possible to use SAS code in defining object function in proc OPTMODEL? in SAS Academy for Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653317#M864</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13941"&gt;@SPR&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks ballardw for your reply. However I need more clarification. Assume we have a code:&lt;BR /&gt;Proc OPTMODEL;&lt;BR /&gt;...&lt;BR /&gt;max y= data a; set b; y+c**2; run;&lt;BR /&gt;...&lt;BR /&gt;quit;&lt;BR /&gt;My question is: will this procedure stop hitting data step "run;" or will continue up to "quit;"?&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My general answer is to try it and see. (Save data an code before hand just in case you manage to create a truly pathological error that renders the SAS session unstable.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't use OPTMODEL but I am fairly sure that when you write a constraint, such as in your example, that "data" is going to be interpreted as a variable and would expect an operator between the variable "data" and the variable "a". The first ; would end the constraint and what follows would start a new statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jun 2020 16:28:53 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-06-04T16:28:53Z</dc:date>
    <item>
      <title>Is it possible to use SAS code in defining object function in proc OPTMODEL?</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653244#M861</link>
      <description>&lt;P&gt;SAS course on proc OPTMODEL suggests that object function can be defined by simple formula: e.g. MAX Y=X**2. Is possible to use more complicated SAS code (execute macros, SQL queries, data steps etc.) in this case?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 14:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653244#M861</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2020-06-04T14:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use SAS code in defining object function in proc OPTMODEL?</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653249#M862</link>
      <description>&lt;P&gt;If the macro generates function code without other procedures it could. Remember all that SAS macro code does is generate code. So what it is acceptable depends on where it starts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As soon as SAS encounters a procedure other than the one currently being used or the start of a data step that current procedure will consider that a "run;" has been implied and attempt to execute with the code.&lt;/P&gt;
&lt;P&gt;Consider:&lt;/P&gt;
&lt;PRE&gt;Proc print data=sashelp.class;

Proc print data=sashelp.cars;&lt;/PRE&gt;
&lt;P&gt;The first Proc Print executes because when the second Proc Print is called SAS implies a Run; before the second. So you get output for printing Sashelp.class. The second Proc print does not have a run statement or a procedure boundary so will sit there waiting for either more proc print options, a run or another Proc/data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 14:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653249#M862</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-04T14:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use SAS code in defining object function in proc OPTMODEL?</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653262#M863</link>
      <description>Thanks ballardw for your reply. However I need more clarification. Assume we have a code:&lt;BR /&gt;Proc OPTMODEL;&lt;BR /&gt;...&lt;BR /&gt;max y= data a; set b; y+c**2; run;&lt;BR /&gt;...&lt;BR /&gt;quit;&lt;BR /&gt;My question is: will this procedure stop hitting data step "run;" or will continue up to "quit;"?&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Thu, 04 Jun 2020 15:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653262#M863</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2020-06-04T15:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use SAS code in defining object function in proc OPTMODEL?</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653317#M864</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13941"&gt;@SPR&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks ballardw for your reply. However I need more clarification. Assume we have a code:&lt;BR /&gt;Proc OPTMODEL;&lt;BR /&gt;...&lt;BR /&gt;max y= data a; set b; y+c**2; run;&lt;BR /&gt;...&lt;BR /&gt;quit;&lt;BR /&gt;My question is: will this procedure stop hitting data step "run;" or will continue up to "quit;"?&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;My general answer is to try it and see. (Save data an code before hand just in case you manage to create a truly pathological error that renders the SAS session unstable.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't use OPTMODEL but I am fairly sure that when you write a constraint, such as in your example, that "data" is going to be interpreted as a variable and would expect an operator between the variable "data" and the variable "a". The first ; would end the constraint and what follows would start a new statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 16:28:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653317#M864</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-04T16:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to use SAS code in defining object function in proc OPTMODEL?</title>
      <link>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653333#M865</link>
      <description>Thanks for clarification. It seems to to I found possible solution to use SAS code inside proc OPTMODEL: it is CALL FCMP. I can do a lot of programming inside the function to calculate complicated object function.</description>
      <pubDate>Thu, 04 Jun 2020 16:34:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Academy-for-Data-Science/Is-it-possible-to-use-SAS-code-in-defining-object-function-in/m-p/653333#M865</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2020-06-04T16:34:47Z</dc:date>
    </item>
  </channel>
</rss>

