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?
@SPR wrote:
Thanks ballardw for your reply. However I need more clarification. Assume we have a code:
Proc OPTMODEL;
...
max y= data a; set b; y+c**2; run;
...
quit;
My question is: will this procedure stop hitting data step "run;" or will continue up to "quit;"?
Thanks
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.)
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.
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.
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.
Consider:
Proc print data=sashelp.class; Proc print data=sashelp.cars;
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.
@SPR wrote:
Thanks ballardw for your reply. However I need more clarification. Assume we have a code:
Proc OPTMODEL;
...
max y= data a; set b; y+c**2; run;
...
quit;
My question is: will this procedure stop hitting data step "run;" or will continue up to "quit;"?
Thanks
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.)
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.
This is a knowledge-sharing community for learners in the Academy. Find answers to your questions or post here for a reply.
To ensure your success, use these getting-started resources:
Estimating Your Study Time
Reserving Software Lab Time
Most Commonly Asked Questions
Troubleshooting Your SAS-Hadoop Training Environment
Ready to level-up your skills? Choose your own adventure.