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
- /
- Base SAS Programming
- /
- Evaluate normal quantile function at 1 or 0

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

12-16-2016 09:09 AM

I am trying to translate code from R into SAS. In R I can evaluate the normal quantile function on the [0,1] intervall. E.g.

qnorm(1) [1] Inf

However, if I do this in SAS with the following code

y=QUANTILE("NORMAL", 1);

I get an error message and the result is a missing value. (Note: between 0 and 1 the function works fine)

Is there a possibility to get Inf (.I) as a result (without manually capturing the cases)?

Accepted Solutions

Solution

12-20-2016
07:29 AM

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

Posted in reply to philip_

12-19-2016 01:44 PM

Your quote is from the SAS/IML documentation and it probably refers to the use of .M and .P as endpoints for numerical integration on infinite domains, as implemented in the QUAD subroutine.

Mathematically, the domain of a quantile function is the open interval (0, 1). You can trap out-of-domain errors by using the ideas in the article "Trap and cap: Avoid division by zero and domain errors when evaluating functions." For quantiles, it might look like this:

```
data Q;
input prob @@;
if prob <=0 then q = .M;
else if prob>=1 then q = .P;
else q = quantile("Normal", prob);
datalines;
-1 0 .1 .5 .9 1 1.2
;
proc print; run;
```

You could also define a user-defined format to print .M as "-Infinity" and .P as "+Infinity."

Traditional SAS supports 27 missing value: ., ._, and .A, ..., .Z. You can choose to interpret these missing values any way you want in your programs. However, most numerical functions (SQRT, LOG, EXP,...) accept any missing value and return the generic missing value (.).

All Replies

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

Posted in reply to philip_

12-16-2016 11:43 AM

You could write your own qnorm() with FCMP. However, I don't know that SAS handles ".I" any differently than other missing values, including ".".

PG

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

Posted in reply to PGStats

12-19-2016 10:00 AM

PG, thanks for your reply. Regarding ".I", I misinterpreted this link: http://support.sas.com/documentation/cdl/en/imlug/63541/HTML/default/viewer.htm#imlug_r_sect019.htm. It states: "Some applications use **.I** to represent positive infinity and use **.M** to represent negative infinity."

But this brings me to a closely related question: Is there a symbol in SAS for infinity and could SAS handle inifity as an input? E.g. is something like this possible: CDF("Normal", infinity) which I expect to return 1.

Thanks in advance.

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

Posted in reply to philip_

12-19-2016 01:43 PM

To my knowledge, only the DIVIDE function handles .I and .M in a special way. Everywhere in SAS Base, the values . and .A-.Z are treated as missing values. You could say that SAS has adopted a pragmatic approach to computation. It is limited to finite values that can be represented with the floating point hardware :

26 data _null_; 27 ataninf = atan(.i); 28 expminf = exp(.m); 29 expmlarge = exp(-1e200); 30 isZero = expmlarge = 0; 31 put ataninf= expminf= expmlarge= iszero=; 32 run; ataninf=. expminf=. expmlarge=0 isZero=1

PG

Solution

12-20-2016
07:29 AM

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

Posted in reply to philip_

12-19-2016 01:44 PM

Your quote is from the SAS/IML documentation and it probably refers to the use of .M and .P as endpoints for numerical integration on infinite domains, as implemented in the QUAD subroutine.

Mathematically, the domain of a quantile function is the open interval (0, 1). You can trap out-of-domain errors by using the ideas in the article "Trap and cap: Avoid division by zero and domain errors when evaluating functions." For quantiles, it might look like this:

```
data Q;
input prob @@;
if prob <=0 then q = .M;
else if prob>=1 then q = .P;
else q = quantile("Normal", prob);
datalines;
-1 0 .1 .5 .9 1 1.2
;
proc print; run;
```

You could also define a user-defined format to print .M as "-Infinity" and .P as "+Infinity."

Traditional SAS supports 27 missing value: ., ._, and .A, ..., .Z. You can choose to interpret these missing values any way you want in your programs. However, most numerical functions (SQRT, LOG, EXP,...) accept any missing value and return the generic missing value (.).