Programming the statistical procedures from SAS

SAS integration that could not be solved in closed form

Reply
Super Contributor
Posts: 298

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,547

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};

call quad(answer, "Func", interval);
print answer;

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: 298

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};

call quad(answer, "Func", interval);

create kaplan1n var{A  B Answer };

append;

quit;

SAS Super FREQ
Posts: 3,547

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

Apparently this thread is continuing here: https://communities.sas.com/message/229999#229999

Ask a Question
Discussion stats
  • 3 replies
  • 284 views
  • 0 likes
  • 2 in conversation