Learning SAS? Welcome to the exclusive online community for all SAS learners.

New to Proc FCMP and Need Help with with SOLVE feature...

Accepted Solution Solved
Reply
Occasional Learner
Posts: 1
Accepted Solution

New to Proc FCMP and Need Help with with SOLVE feature...

I'm working on a GIS project and was asked to validate a method used in a recently published article. One of the many steps to do this involves "back-solving" for a variable thats in a fraction within an exponent (pic below [solving for dxy]). Though the forumla looks complex, I think that the solve feature within proc fcmp should help me get a solution quicker without me having to do any time consuming algebra (e.g., ln(e)*ln(fraction)...). To test the SOLVE feature, I used the following inputs from the previously hyperlinked article knowing that I should get dxy=24.61 (or something close) as the solution: 

  • median=20
  • SD=6
  • Cglob=30
  • SDglob=5.91

I set the formula below to zero within my code (i.e., subtract 0.01 from both sides). That said, when I use proc fcmp to solve for "dxy", I get a missing value (i.e., ".") instead of the answer I should get (i.e., ~24.61).

 

Is there something I doing wrong? Is proc fcmp inappropriate for my needs? ANY feedback will be appreciative, as I am having difficulty finding a solution online. My SAS code is below the pic of the forumla. 

 

 

Wanting to solve for dxy within formula below assuming you know all other paramters/inputs:

 

FCMP formula.png

 

SAS Code:

 

proc fcmp outlib=work.funcs.algebra;
function effect_catch(median, SD, Cglob, SDglob, dxy) ;
 return ( (((1+exp(-(median*constant("pi"))/(SD*sqrt(3))))/(1+exp(((dxy-median)*constant("pi"))/(SD*sqrt(3)))))
		*
		((1+exp(-((Cglob/2)*constant("pi"))/(SDglob*sqrt(3))))/(1+exp(((dxy-(Cglob/2))*constant("pi"))/(SDglob*sqrt(3))))))
		-0.01);
 endsub;

function solvecatch(median, SD, Cglob, SDglob);
 dxy=solve('effect_catch', {.}, 0, median, SD, Cglob, SDglob,.);
 return(dxy);
 endsub;
quit;

options cmplib=work.funcs;

data test;
 dxy=solvecatch(20, 6, 30, 5.91);
 put dxy=;
 run;

 


Accepted Solutions
Solution
‎12-16-2016 11:18 AM
Super User
Posts: 9,681

Re: New to Proc FCMP and Need Help with with SOLVE feature...

It is trying to find a function root. Better post it at IML forum.


proc iml;
start effect_catch(dxy) global(median, SD, Cglob, SDglob);
 obj= ( (((1+exp(-(median#constant("pi"))/(SD#sqrt(3))))/(1+exp(((dxy-median)#constant("pi"))/(SD#sqrt(3)))))
		#
		((1+exp(-((Cglob/2)#constant("pi"))/(SDglob#sqrt(3))))/(1+exp(((dxy-(Cglob/2))#constant("pi"))/(SDglob#sqrt(3))))))
		-0.01);
 return (obj);
finish;
median=20;SD=6;Cglob=30;SDglob=5.91;
root=froot('effect_catch',{-100 100});print root;
quit;



OUTPUT:
root
24.613412


View solution in original post


All Replies
Solution
‎12-16-2016 11:18 AM
Super User
Posts: 9,681

Re: New to Proc FCMP and Need Help with with SOLVE feature...

It is trying to find a function root. Better post it at IML forum.


proc iml;
start effect_catch(dxy) global(median, SD, Cglob, SDglob);
 obj= ( (((1+exp(-(median#constant("pi"))/(SD#sqrt(3))))/(1+exp(((dxy-median)#constant("pi"))/(SD#sqrt(3)))))
		#
		((1+exp(-((Cglob/2)#constant("pi"))/(SDglob#sqrt(3))))/(1+exp(((dxy-(Cglob/2))#constant("pi"))/(SDglob#sqrt(3))))))
		-0.01);
 return (obj);
finish;
median=20;SD=6;Cglob=30;SDglob=5.91;
root=froot('effect_catch',{-100 100});print root;
quit;



OUTPUT:
root
24.613412


☑ This topic is SOLVED.

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

Discussion stats
  • 1 reply
  • 258 views
  • 0 likes
  • 2 in conversation