## SAS integration that could not be solved in closed form

Super Contributor
Posts: 303

# SAS integration that could not be solved in closed form

How can integrate this function in SAS. Limit of integration is  a and b.

exp(2-x) CDF(X) dx

SAS Super FREQ
Posts: 3,839

## Re: SAS integration that could not be solved in closed form

Is the CDF of a well-known distribution?  If so, you can use the CDF function in SAS as part of the integrand.

To compute a numerical  integration with known limits of integration, use the QUAD call in PROC IML. For the standard normal CDF and [a,b] = [0,1], the call would look like this:

start Func(x);
return(  exp(2-x)#cdf("Normal", x) );
finish;

interval = {0 1};

For more on numerical integration with SAS, I have written several blog posts. You might want to do an internet search for

integrate function site:http://blogs.sas.com/content/iml/

and include other keywords as necessary.

Super Contributor
Posts: 303

## Re: SAS integration that could not be solved in closed form

Hello Rick,

Thank for your help. I am trying to do this numerical integration within a simulation. I used your code and read through the site but I am having one issue in the code below;

Data sim;

Input A B;

cards;

1 3

2 7

3 10

4 12

;

Run;

proc iml;

use sim;

read all  var{A B} into DM;

close;

A = DM[,1]; B = DM[,2];

n = nrow(DM);

start Func(x);

return(  exp(2-x)#cdf("Normal", x) );

finish;

interval = {A, B};

create kaplan1n var{A  B Answer };

append;

quit;

SAS Super FREQ
Posts: 3,839