BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
skipper
Calcite | Level 5

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!!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

4 REPLIES 4
skipper
Calcite | Level 5

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

PGStats
Opal | Level 21

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
PGStats
Opal | Level 21

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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