SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
sthudson0
Calcite | Level 5

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

4 REPLIES 4
Reeza
Super User

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;

 

 

 

sthudson0
Calcite | Level 5

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

PGStats
Opal | Level 21

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

PG
FreelanceReinh
Jade | Level 19

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.

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 4267 views
  • 2 likes
  • 4 in conversation