BookmarkSubscribeRSS Feed
tonghui1127
Calcite | Level 5

how to use absolute function in proc model to solve nonlinear equations. 

3 REPLIES 3
tonghui1127
Calcite | Level 5

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.


PREDICTSIMULATE0.00010.70.77711586222
PREDICTSIMULATE0.00010.70.758104117221
PREDICTSIMULATE0.00010.70.758112111219
PREDICTSIMULATE0.00010.70.774110109207
PREDICTSIMULATE0.00010.70.76893125214
PREDICTSIMULATE0.00010.70.76211095233
PREDICTSIMULATE0.00010.70.764104113219
PREDICTSIMULATE0.00010.70.75710394246
PREDICTSIMULATE0.00010.70.770106114210
Kurt_Bremser
Super User

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 947 views
  • 0 likes
  • 2 in conversation