Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

Minimize Number By Changing Another Number

New User
Posts: 1

Minimize Number By Changing Another Number

Hi everyone,

I used excel's solver for this problem. It works. But now I need to use SAS. I am kind of new to SAS. So, any help would be appreciated. And Here is my problem.

I have 3 matrices(or data set).

1. and 3. are Constant.  2. matrix changes with an index value(I need to find this value by changing until  sum of percentage error of matrix 2 and matrix 3 becomes less than 0.0001. Here are the example matrices.

1. Matrix Z values of normal dist.(example)                


2. Matrix( Depends on First Matrix and Index Value).

At the beginning second matrix is empty.

We calculate     2. Matrix Cell[1,1] = probit(1. matrix[1,1] - Index Value)

If sum of squared per. error is not small enough. We should apply new index and This matrix will change again.


3. Matrix is always constant as the 1. matrix


And Then We calculate percentage error between 2. and 3. matrix for every cell.  ( ( 3.Matrix[1,1] - 2. Matrix[1,1])/ 3Matrix[1,1]) ^2   then sum all of them.

So Sum of these numbers should be less than 0.0001 and I should do this  by changing index value. If sum of percentage errors are small enough. Then that is the index value that i am looking for.

Even simple examples would help. Maybe I can try to apply them by myself. There are some examples online. I couldnt find way to apply to this situation. Thanks in advance to everyone.

Super User
Posts: 10,610

Re: Minimize Number By Changing Another Number

You are operating a Matrix , you'd better post it at

and there is a problem. probit(p)  should be 0<p<1 . but in your sample data they can't be true in sometime .

Anyway, here is some data step code you can refer to , But I suggest you post it at IML forum.

data one;
input t1-t5;
-1.34     0.45     -1.22     0.11     0.99
-1.1     0.2     0.3     0.23     0.99
%let index=0.5;
data two(keep=_t:);
set one;
array one{*} t1-t5;
array two{*} _t1-_t5;
do i=1 to dim(one);
 two{i}=probit(one{i}-&index );
data three;
input t1-t5;
0.89     0.45     0.22     0.11     0
0.2     0.7     0.5     0.23     0.1
data error(keep=e:);
 merge three two;
 array three{*} t1-t5;
 array two{*} _t1-_t5;
 array error{*} e1-e5;
 do i=1 to dim(error);
  error{i}= (divide((three{i}-two{i}),three{i}))**2;

Xia Keshan

SAS Employee
Posts: 538

Re: Minimize Number By Changing Another Number

Here's one way to use PROC OPTMODEL to solve this optimization problem with one decision variable:

proc optmodel;
   set ISET;
   set JSET = 1..5;
   num one {ISET, JSET};
   num three {ISET, JSET};
   read data one into ISET=[_N_] {j in JSET} <one[_N_,j]=col('t'||j)>;
   read data three into [_N_] {j in JSET} <three[_N_,j]=col('t'||j)>;

   var Index;
   impvar Two {i in ISET, j in JSET} = probit(one[i,j] - Index);
   min TotalError = sum {i in ISET, j in JSET} ((three[i,j]-Two[i,j])/three[i,j])^2;

   print Two;
   print Index;

But you need to clean up the data before you can use PROBIT.

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation