BookmarkSubscribeRSS Feed
ertr
Quartz | Level 8

Hi everybody,

 

I can calculate BINOM.DIST with the PDF function in SAS, but I'm looking for the equivalent of the BINOM.DIST.RANGE function. Let me give you an example;

 

DATA Have;
Length Bucket 8 Obs 8 Defaults 8 Avg_PD 8 ;
Infile Datalines Missover Dlm=",";
Input Bucket Obs Defaults Avg_PD;
Format Avg_PD Percent8.2;
Datalines;
1,300,5,0.01
2,1000,20,0.02
3,2000,80,0.04
4,2000,100,0.05
5,2000,150,0.07
6,1000,80,0.08
7,800,100,0.12
8,200,20,0.14
;

DATA WANT;
SET HAVE;
DR=Defaults/Obs;
PValue=PDF('BINOMIAL',Defaults/*number of successes*/,DR /*probability of success*/,Obs/*number of trails*/);
Run;

I'm trying to get the same results in SAS as in the Excel table below.

 

BucketObsDefaultsAvg PDDRP-Value
130051,0%1,7%18,39%
21000202,0%2,0%53,06%
32000804,0%4,0%51,58%
420001005,0%5,0%51,43%
520001507,0%7,5%20,14%
61000808,0%8,0%51,67%
780010012,0%12,5%34,73%
82002014,0%10,0%96,33%

 

PValue = =BINOM.DIST.RANGE(Obs;AvgPd;Defaults;Obs)

 

Your help is greatly appreciated; thanks in advance.

2 REPLIES 2
ballardw
Super User

Define what "BINOM.DIST.RANGE" might actually be.

If you expect to have the range of a binomial distribution it would typically be 0 to number of trials as potential min/max value regardless of probability of success, just very unlikely to see the min or max for some given probability of success.

 

I don't understand what your example or output table is attempting to say. P-values are the result of tests, not statistics. So I am not at all clear what that relation would be with Range.

 

Please be very carefully about phrasing function names or similar using non-SAS language constructs. In SAS Binom.dist would be either a library named Binom and data set named dist, or in Sql  a table named or with an alias of Binom and a variable named dist in most common syntax. In a data step and a few other places you could be attempting to use SCL constructs that just do no exist. So for clarity of questions use either SAS syntax or plain language.

FreelanceReinh
Jade | Level 19

Hi @ertr,

 

In your example, where the fourth argument of the Excel function equals the first, you can use the SDF function like this:

data want;
set have;
DR=Defaults/Obs;
p_Value=SDF('BINOMIAL',Defaults-1,Avg_PD,Obs);
format Avg_PD DR nlpct7.1 p_value nlpct8.2;
run;

 

Edit: In the general case (i.e., with a non-trivial upper limit of the interval in the fourth argument in Excel, let's call it maxDefaults) you can use a difference of two CDF function values:

p=CDF('BINOMIAL',maxDefaults,Avg_PD,Obs)-CDF('BINOMIAL',Defaults-1,Avg_PD,Obs);

If you omit the fourth argument in Excel, you get the value of the (SAS) PDF function:

p=PDF('BINOMIAL',Defaults,Avg_PD,Obs);

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 518 views
  • 1 like
  • 3 in conversation