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
- /
- Quantile for chi square

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

02-20-2016 06:16 PM

Hello,

I am trying to use SAS for the first time and I am stuck. My first homework problem is : Find the quantile for chi squared with 4 df at a probablity of .47.

How can I write this program?

Thank you fo rnay help you can give me.

sthudson0

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

02-20-2016 06:39 PM

My stats is getting rusty these days, but I think you're looking for one of the following:

cumulative distribution function for chi square (CDF) - not likely

probability distribution function for chi square (PDF) - possible

Cumulative inverse - quantile (CINV) - likely

```
data want;
prob=0.47;
df=4;
y=probchi(0.47, 4);
z=cinv(0.47, 4); *<-most likely this number;
run;
```

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

02-20-2016 06:57 PM

Thank you very much. I wil lgive this a try.

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

02-21-2016 12:14 AM

quantile('CHISQ', .47, 4); /* definitely */

PG

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

02-23-2016 07:54 AM

Just a side note: It seems that the two functions are implemented differently. In this particular case the results differ in the last bit (i.e. 2^-51) on my Windows machine. (Irrelevant for practical purposes, of course.)

```
data _null_;
c=cinv(.47, 4);
q=quantile('CHISQ', .47, 4);
if c ne q then do;
put 'Not exactly equal.';
d=c-q;
put 'Difference: ' d;
put (c q) (hex16. /);
end;
run;
```

So, which one is closer to the "true" result?

Well, it depends ... For the exact argument of 0.47=47/100 *c* is closer, but for the internal 64-bit floating-point representation of 0.47 (which equals 0.47 - 0.96*2^-55) *q* is closer, says my computer algebra software.