Turn on suggestions

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

Showing results for

Options

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

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 07-10-2020 10:37 PM
(573 views)

Community,

I want to perform a numerical integration for the following integrand

C1, delta11, d1, rho are all scalar, which will be specified explicitly. \phi(u) is the PDF of a standard normal distribution, \Phi() is the CDF of a standard normal distribution. I proposed the following SAS codes, but I failed, so there must be something very wrong. Can you kindly help? Thanks in advance!

*************************************************************************************************

proc iml;

start stdn(u);

pi = constant("Pi");

z=(1/sqrt(2#pi))#exp((-1/2)#(u#u));

return(z);

finish;

start phi(u) global(d1,rho);

cdf=probnorm((-d1+rho#u)/sqrt(1-rho#rho));

return(cdf);

finish;

start grand(u);

v=phi#stdn;

return(v);

finish;

start integral(cc1,ddelta1,dd1,rrho) global(c1,delta1,d1,rho,eps);

c1=cc1;

delta1=ddelta1;

d1=dd1;

rho=rrho;

ll=c1-delta1;

interval=ll||.P;

call quad(final,"grand",interval) eps=eps;

return(final);

finish;

eps = 1E-11;

p=integral(1.678, 1, 1.645, 0.6);

print p;

run;

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

As Ian points out, the mistake in the 'grand' function. Try

```
start grand(u);
v=phi(u)#stdn(u);
return(v);
finish;
```

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

"Failed" is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the <> to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data, if any, in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

Or how do you know it failed?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

As Ian points out, the mistake in the 'grand' function. Try

```
start grand(u);
v=phi(u)#stdn(u);
return(v);
finish;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thanks a lot Rick, it works. I will reply to Ian to thank him as well.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.