Power Curve for Binomial Distribution A regional Marketing manager feels that his company has cornered $40$% of the typewriter market in a specific area. Taking $p = .4$ as the null hypothesis, the manager decides to consider this claim reasonable unless a sample of $19$ sales shows $X$ $\leq$ $3$ or $X$ $\geq$ $12$, where X denotes the number of typewriters sold by his company. 
(a) Find $\alpha$ for this test.
(b) Find the power of the test for several values of p between $.1$ and $.9$ and plot the power curve. 
Attempted Solution:
(a) $\alpha = \Pr(\text{rejection of $H_0$ when $H_0$ is true})$
$\Pr(X \leq 3) + \Pr(X \geq 12) = 0.058$
(b) When the p values are $.1, .2, .3, .4, .5, .6, .7, .8, .9$, I get that the probabilities of being in the rejection region are $.885, .455, .136, .058, .182, .488, .818, .977$, and $.999$, respectively. This produces the graph below. 
I was hoping to see if I did this correctly, and if anyone knows how to graph this in SAS.

 A: Checking:
(a)  Under $H_0: p = .4,$  the test statistic $X \sim \mathsf{Binom}(n = 19, p=.4).$  The rejection region in terms of $X$ is $\{X \le 3\} \cup \{X \ge 12\}.$
$\alpha = P(\text{Rej}\mid H_0) = P(\text{Rej}\mid p=.4) = P(X\le 3) + P(X \ge 12) =  0.058 ,$ as found using
R statistical software.  So this part is OK.
pbinom(3, 19, .4) + (1 - pbinom(11, 19, .4))  # using CDF 'pbinom'
## 0.05818722
rr = c(0:3, 12:19);  sum(dbinom(rr, 19, .4))  # using PDF 'dbinom'
## 0.05818722

(b) According to your page of work, you seem to be using $\gamma(p)$
for the power, that is $\gamma(p) = P(\text{Rej}\mid p).$  You wish to plot
$\gamma(p)$ against $p$ for various values of $p$ with $.1 \le p \le .9.$
First, I will use R to make a table for values $p = .1, .2, \dots, .9,$
in order to verify the answers you got.
p = seq(.1, .9, by=.1)    
p.rej = pbinom(3, 19, p) + (1 - pbinom(11, 19, p))
cbind(p, p.rej)
        p      p.rej
 [1,] 0.1 0.88500247
 [2,] 0.2 0.45513853
 [3,] 0.3 0.13599359
 [4,] 0.4 0.05818722
 [5,] 0.5 0.18185425
 [6,] 0.6 0.48787653
 [7,] 0.7 0.81803204
 [8,] 0.8 0.97672169
 [9,] 0.9 0.99972668

Except for rounding, these values seem to agree with yours.
In order to make a smooth power curve, I will pick more values of $p$ closer
together.
p = seq(.1, .9, by=.01)    
p.rej = pbinom(3, 19, p) + (1 - pbinom(11, 19, p))
plot(p, p.rej, type="l", lwd=2, ylim=0:1, col="blue", main="Power Curve")
  abline(h=0:1, col="green2");  abline(v=.4, col="green2")


The vertical green line at the hypothetical value $p = 0.4$ crosses the
curve at the significance level $\alpha.$ Strictly speaking this one point
is not a power value. It is appropriate to label the vertical axis
as 'P(Rej)'.
It is possible that SAS has a procedure for binomial tests and that there
is an option in that procedure to make a power curve. Otherwise, you will
have to do something in SAS similar to what I did in R. R makes heavy use
of vector objects, so that one statement will generate all of the power
values. In SAS, you may have to write a loop to go through the values of
$p$ one at a time. Also, it is possible that your release of SAS will link
to R and you can use essentially the same R code I did.
