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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1 reply
  • 2072 views
  • 2 likes
  • 1 in conversation