DATA Step, Macro, Functions and more

Can someone help me with the following please?

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

Can someone help me with the following please?

According to the American Lung Association, 85% of adult smokers started smoking before turning 21 years old. Ten smokers 21 years old or older are randomly selected, and the number of smokers who started smoking before 21 is recorded.

  • Find the probability that exactly 8 of them started smoking before 21 years of age.
  • Find the probability that fewer than 8 of them started smoking before 21 years of age.
  • Find the probability that at least 8 of them started smoking before 21 years of age.
  • Find the probability that between 7 and 9 of them started smoking before 21 years of age.

Accepted Solutions
Solution
‎03-01-2017 11:33 PM
Trusted Advisor
Posts: 1,022

Re: Can someone help me with the following please?

a


pacruz wrote:

So far I have the following but I cannot figure out the last question.

 

 

find the probability that between 7 and 9 of them starte smoking before 21 year of age.


   p4=probbnml(0.85,10,9)-probbnml(0.85,10,6);   /* =cdf(9)-cdf(6) */

View solution in original post


All Replies
Super User
Posts: 7,808

Re: Can someone help me with the following please?

Please post your base data (data step with datalines), the code you already have, and where the result differs from your expectations.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Trusted Advisor
Posts: 1,022

Re: Can someone help me with the following please?

Isn't this satisfied by using the PROBBNML function?

 

    Binomial Cumulative Distribution Function = probbnml(p,N,s),    where
      p=baseline probability   (0.85 in your case)
      N=number of trials
      S=number of successes

 

  Note that binomial prob of s=K    is cdf(K) - cdf(K-1)

PROC Star
Posts: 7,474

Re: Can someone help me with the following please?

With a sample size of only 10, I wouldn't trust the p values. Take a look at: https://onlinecourses.science.psu.edu/stat414/node/264

 

 

Art, CEO, AnalystFinder.com

 

Contributor
Posts: 21

Re: Can someone help me with the following please?

I tried using your code but it gave an error. If I have the following code how can I use to solve the problem?

 

data binom_table;
array p(6);
do x=0 to 5;
p(x+1)=probbnml(.4,5,x);
end;

Respected Advisor
Posts: 4,925

Re: Can someone help me with the following please?

Once you understand that the probabilities are binomial (10 smokers, each of them having a 0.85 probability of having started smoking before age 21), all you need is to get the probabilities:

 

data _null_;
n = 10;
do i = 0 to n;
    p = pdf("BINOMIAL", i, 0.85, n);
    cum = cdf("BINOMIAL", i, 0.85, n);
    ccum = 1 - cum;
    put i= p= cum= ccum=;
    end;
format p cum ccum pvalue8.5 i z2.;
run;

  • Find the probability that exactly 8 of them started smoking before 21 years of age. = p(i=8)
  • Find the probability that fewer than 8 of them started smoking before 21 years of age. = cum(7)
  • Find the probability that at least 8 of them started smoking before 21 years of age. = ccum(8)
  • Find the probability that between 7 and 9 of them started smoking before 21 years of age. = p(7) + p(8) + p(9)

 

 

 

PG
Contributor
Posts: 21

Re: Can someone help me with the following please?

So far I have the following but I cannot figure out the last question.

 

data binomial;

array p(3) p1-p3;

p(1)=probbnml(0.85,10,8)-probbnml(0.85,10,8);

p(2)=probbnml(0.85,10,7);

p(3)=1-probbnml(0.85,10,8);

run;

proc print;

var p1-p3;

run;

 

find the probability that between 7 and 9 of them starte smoking before 21 year of age.

Solution
‎03-01-2017 11:33 PM
Trusted Advisor
Posts: 1,022

Re: Can someone help me with the following please?

a


pacruz wrote:

So far I have the following but I cannot figure out the last question.

 

 

find the probability that between 7 and 9 of them starte smoking before 21 year of age.


   p4=probbnml(0.85,10,9)-probbnml(0.85,10,6);   /* =cdf(9)-cdf(6) */

Contributor
Posts: 21

Re: Can someone help me with the following please?

Thank you!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 176 views
  • 2 likes
  • 5 in conversation