how to use absolute function in proc model to solve nonlinear equations.
@tonghui1127 wrote:
how to use absolute function in proc model to solve nonlinear equations.
Like you use it in a data step, it is the same function.
Dear KurtBremser
Thank you for your rely.
This is my SAS code, when i use proc model to solve pie1 , I think there has some values are negative. So I want to use ABS() function in my formula to make sure there is no negative values. But this is not work.
proc model data = data2 out = data3;
eq.f = (p*t*pie1+(1-p)*(1-t)*(1-pie1)-x1/&NumTrials)
+(p*(1-t)*pie1+(1-p)*t*(1-pie1)-x2/&NumTrials)
+((1-p)*t*pie1+p*(1-t)*(1-pie1)-x3/&NumTrials)
+((1-p)*(1-t)*pie1+p*t*(1-pie1)-x4/&NumTrials);
solve pie1;
proc print data = data3;
run;
This is the result i got after run code, the pie1 is .0001 , i don't know how to fix this problem.
PREDICT | SIMULATE | 0 | .0001 | 0.7 | 0.7 | 77 | 115 | 86 | 222 |
PREDICT | SIMULATE | 0 | .0001 | 0.7 | 0.7 | 58 | 104 | 117 | 221 |
PREDICT | SIMULATE | 0 | .0001 | 0.7 | 0.7 | 58 | 112 | 111 | 219 |
PREDICT | SIMULATE | 0 | .0001 | 0.7 | 0.7 | 74 | 110 | 109 | 207 |
PREDICT | SIMULATE | 0 | .0001 | 0.7 | 0.7 | 68 | 93 | 125 | 214 |
PREDICT | SIMULATE | 0 | .0001 | 0.7 | 0.7 | 62 | 110 | 95 | 233 |
PREDICT | SIMULATE | 0 | .0001 | 0.7 | 0.7 | 64 | 104 | 113 | 219 |
PREDICT | SIMULATE | 0 | .0001 | 0.7 | 0.7 | 57 | 103 | 94 | 246 |
PREDICT | SIMULATE | 0 | .0001 | 0.7 | 0.7 | 70 | 106 | 114 | 210 |
If you want to prevent negative values of pie1 in your solution, either set them to zero by using the max() function, eg
max(pie1,0)
instead of just pie1, or use a where condition on the dataset to discard such observations.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.