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)
t1 | t2 | t3 | t4 | t5 |
---|---|---|---|---|
-1.34 | 0.45 | -1.22 | 0.11 | 0.99 |
-1.1 | 0.2 | 0.3 | 0.23 | 0.99 |
... | ... | ... | ... | ... |
... | ... | ... | ... | ... |
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.
t1 | t2 | t3 | t4 | t5 |
---|---|---|---|---|
. | . | . | . | . |
. | . | . | . | . |
... | ... | ... | ... | ... |
... | ... | ... | ... | ... |
3. Matrix is always constant as the 1. matrix
t1 | t2 | t3 | t4 | t5 |
---|---|---|---|---|
0.89 | 0.45 | 0.22 | 0.11 | 0 |
0.2 | 0.7 | 0.5 | 0.23 | 0.1 |
... | ... | ... | ... | ... |
... | ... | ... | ... | ... |
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.
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; cards; -1.34 0.45 -1.22 0.11 0.99 -1.1 0.2 0.3 0.23 0.99 ; run; %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 ); end; run; data three; input t1-t5; cards; 0.89 0.45 0.22 0.11 0 0.2 0.7 0.5 0.23 0.1 ; run; 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; end; run;
Xia Keshan
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;
solve;
print Two;
print Index;
quit;
But you need to clean up the data before you can use PROBIT.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.