BookmarkSubscribeRSS Feed
gupta_shubham
Obsidian | Level 7

I want to solve a optimization problem where my objective function includes call of a user defined function. Since SAS do not allow us to create a user-defined function I have to use a macro to use it as if it is a function.

I am stating my problem mathematically below:

var x, y;

min z =x**2-x-2*y-x*y+y**2+function(x,y); 

solve;

print x y;

function (x,y)=x+y;

Above function is very simple but it is analogous to my function which is very complicated.

So how should I do this kind of optimization in SAS using proc optmodel.

Thanks in advance for your support.

5 REPLIES 5
gupta_shubham
Obsidian | Level 7

Actually I want to use data step inside the function. And I can't use data step inside fcmp functions

LeoLopes
SAS Employee

Do the data change in real time? If not, you might be able to load it into PROC OPTMODEL sets and arrays, write an impvar that does the same function evaluation, then use that impvar in your objective.

gupta_shubham
Obsidian | Level 7

Yes data changes are required in real time. So loading data at the start of optmodel won't going to work.

BrianDoesSas
Obsidian | Level 7

Does proc fcmp not let you create your own functions?

Base SAS(R) 9.2 Procedures Guide

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1602 views
  • 0 likes
  • 3 in conversation