Help using Base SAS procedures

which procedure to solve non linear equation

Accepted Solution Solved
Reply
Contributor
Posts: 56
Accepted Solution

which procedure to solve non linear equation

UPDATE: Heres my code

data test;

      input v1 v2 v3 v4 v5;

   datalines;

          0.0230 1.4334 1.46 0.01 0.26

;

run;    

proc model data=test;

      eq.sqrt      = EXP(-v4*v5)*(v2*CDF('NORMAL',(LOG(v2/v3)+v5*(x**2)/2)/(x*SQRT(v5)),0,1)-v3*CDF('NORMAL',((LOG(v2/v3)-v5*(x**2)/2)/(x*SQRT(v5))),0,1))-v1;

      solve x / out=test2;

run;

but it cannot find 'x', which should be simple to find, well in Matlab the fsolve function easily finds it, but in matlab i supply an initial value but here i have not, inital value should be say x=0.3, from memory matlab gave me an answer of 0.118 or something like that;.

my_data has 5 variables with 200 observations.

the variables, all numeric values are v1, v2, v3, v4 and v5

I have a nonlinear function of these variables F(x)=0

F(x) = EXP(-v4*v5)*(v2*CDF('NORMAL',((LOG(v2/v3)+v5*x^2/2)/(x*SQRT(v5))),0,1)-v3*CDF('NORMAL'((LOG(v2/v3)-v5*x^2/2)/(x*SQRT(v5))),0,1))-v1

I want to solve for x, i.e what 'x' value makes the above equation equal zero.

so for each record I want to use the values of 5 variables, put them into the above equation, solve it and return the value of 'x' into the record on the dataset, so i end up with a dataset with 6 variables.

Ive tried searching online but I find it so difficult looking, even with google!!


Accepted Solutions
Solution
‎03-22-2012 11:28 PM
Respected Advisor
Posts: 4,927

which procedure to solve non linear equation

You effectively have to give it a starting value in the input dataset, as in :

data test;
      input v1 v2 v3 v4 v5 x;
   datalines;
          0.0230 1.4334 1.46 0.01 0.26 0.1
;
run;    

proc model data=test;
      eq.first      = EXP(-v4*v5)*(v2*CDF('NORMAL',(LOG(v2/v3)+v5*(x**2)/2)/(x*SQRT(v5)),0,1)-v3*CDF('NORMAL',((LOG(v2/v3)-v5*(x**2)/2)/(x*SQRT(v5))),0,1))-v1;
      solve x / out=test2;
run;

PG

PG

View solution in original post


All Replies
PROC Star
Posts: 7,480

which procedure to solve non linear equation

Contributor
Posts: 56

which procedure to solve non linear equation

yes, I did look, it just looked overly complicated for such a simple procedure

i will have another look, if you think thats the place to findmy answer.

thank you

Respected Advisor
Posts: 4,927

which procedure to solve non linear equation

I managed to get some work done with proc model some time ago. Could you post 3 or 4 typical observations (v1-v5). I'll see if I can find my way back into it.

PG

PG
Solution
‎03-22-2012 11:28 PM
Respected Advisor
Posts: 4,927

which procedure to solve non linear equation

You effectively have to give it a starting value in the input dataset, as in :

data test;
      input v1 v2 v3 v4 v5 x;
   datalines;
          0.0230 1.4334 1.46 0.01 0.26 0.1
;
run;    

proc model data=test;
      eq.first      = EXP(-v4*v5)*(v2*CDF('NORMAL',(LOG(v2/v3)+v5*(x**2)/2)/(x*SQRT(v5)),0,1)-v3*CDF('NORMAL',((LOG(v2/v3)-v5*(x**2)/2)/(x*SQRT(v5))),0,1))-v1;
      solve x / out=test2;
run;

PG

PG
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 224 views
  • 0 likes
  • 3 in conversation