You need to merge the data and the limits. To help do that, use all integer values for the limits. You need to make changes in three places:
1) In the IML program, there is a definition of 'n' as
n = T( do(minN, maxN, (maxN-minN)/20) );
Replace that line with all possible trials:
n = T(minN:maxN);
2) Merge the data and the computed limits:
/* merge data with proportions */
data Adoptions; merge Adoptions Stats; run;
/* merge control limits */
proc sort data=Adoptions; by Trials; run;
data Funnel;
merge Adoptions(rename=(Trials=N)) Limits;
by N;
Label = Authority;
if L3sd <= Proportion <= U3sd then Label=""; /* delete if w/in +/- 3*sigma */
run;
3) Change the SCATTER statement to
scatter x=N y=Proportion / datalabel=Label;
For each observation, you can tell whether it is outside of the 95% confidence interval. Create a label variable that is missing for points inside the CI and .has nonmissing values for points outside the CI, as shown in the article "Label only certain observations with PROC SGPLOT."
Hi @Rick_SAS
Thanks for the reply - I actually spent quite a bit of time yesterday working thourhg that blog, as I figured it was the easiest thing to do. Where I'm stumped is in the "Funnel" dataset, we have "Authority", "Events", Trials", "Proportion", and "Expected"; then, rows 144 - 164 (in the same dataset) have "N", "L3sd", "L2sd", "U2sd", and "U3sd". If I understand correctly, what I need to do is match the number of events for the individual authority (for example, Halton has n=20) with the closest N (in my case, probably N=26) so that i can get the lower/upper CI of 0.435 and 0.956. Where I'm getting stuck is figuring out how to do this; I tried splitting the tables into 2 and then doing a join in SQL but couldn't get it to work.
Based on the article you linked to, here's my result based on Proportion <=0.5 and Proportion >=0.95. This works fine for the N<=60 or so, but because the Proportions drop (and therefore the CIs get narrower), this does not work for the right side of the graph. What I'd like is all the points above the upper red line and below the lower red line to be labelled.
Thanks again for your help. I'm hoping I have explained this clearly - I'm multi-tasking (trying to do work and this at the same time :-)).
Chris
You need to merge the data and the limits. To help do that, use all integer values for the limits. You need to make changes in three places:
1) In the IML program, there is a definition of 'n' as
n = T( do(minN, maxN, (maxN-minN)/20) );
Replace that line with all possible trials:
n = T(minN:maxN);
2) Merge the data and the computed limits:
/* merge data with proportions */
data Adoptions; merge Adoptions Stats; run;
/* merge control limits */
proc sort data=Adoptions; by Trials; run;
data Funnel;
merge Adoptions(rename=(Trials=N)) Limits;
by N;
Label = Authority;
if L3sd <= Proportion <= U3sd then Label=""; /* delete if w/in +/- 3*sigma */
run;
3) Change the SCATTER statement to
scatter x=N y=Proportion / datalabel=Label;
thanks Rick - that was perfect and I actually think I understand what you did 🙂
Have a great evening
Chris
Although simple, tt's a bit of overkill to have 'n' contain all integers. The important thing is that it contains all the trial values in the data, as well as enough evenly spaced values to visualize the funnel. Then you can do the merge, rather than interpolate.
thanks for the further explanation. definitely one of the cooler analyses I've worked on in a while!
Chris
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.