BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
vstorme
Obsidian | Level 7

Dear,

 

I used the code from Rick Wicklin to produce a funnel plot which works really nice. However, In addition I have a grouping variable for which I used a format, but I can't get the order correct of the legend. This is my code (I use SAS 9.4):

 

proc sort data = &lib..Funnel out = sortfunnel;
by mycap;
run;

/*--Make control data set for format--*/
data myfmt;
 set sortfunnel;
    by mycap;
 if first.mycap then do;
    fmtname='typefmt';
    start=mycap;
    label=label;
output;
end;
run;
data myfmt (keep=fmtname start label mycap);
set myfmt ;
if start=. then delete;
run;
/*--Create format--*/
proc format cntlin=myfmt;
run;

/* 4. Plot proportions versus sample size. Overlay control limits */
ods rtf file = "&path.funnelplot.rtf" style=analysis;
options orientation=landscape;
title "My Title";
proc sgplot data=&lib..Funnel NOCYCLEATTRS ;
styleattrs datacontrastcolors=(LILG BILG STLG VILG DELG) ;
band x=N lower=L3sd upper=U3sd / nofill lineattrs=(color=lipk) legendlabel="99.8% limits" name="band99";
band x=N lower=L2sd upper=U2sd / nofill lineattrs=(color=gray) legendlabel="95% limits" name="band95";
refline &AvgProp / axis=y lineattrs=(pattern=longdash color=blue);
scatter x=Trials y=Proportion / group = mycap 
								markerattrs=(symbol=circlefilled size=5 )
								legendlabel="capaciteit" name="cap";
keylegend "band95" "band99" / location=inside position=bottomright;
keylegend "cap" / location=inside position=right  title='capaciteit';
yaxis grid values=(0 to 1 by 0.1) label = "tekst voor Y-as"; 
xaxis grid label = "tekst voor X-as";
format mycap typefmt.;
run;
ods rtf close;
1 ACCEPTED SOLUTION

Accepted Solutions
vstorme
Obsidian | Level 7
I just found the answer, sorting the file first did the trick!

View solution in original post

1 REPLY 1
vstorme
Obsidian | Level 7
I just found the answer, sorting the file first did the trick!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1 reply
  • 2346 views
  • 2 likes
  • 1 in conversation