turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- which procedure to solve non linear equation

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-21-2012 05:21 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-22-2012 11:28 PM

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

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-21-2012 05:32 PM

Have you looked into proc model? Take a look at: http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/viewer.htm#etsug_model_sect006....

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-21-2012 05:43 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-21-2012 09:01 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

03-22-2012 11:28 PM

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