Data visualization with SAS programming

keylegend order when format is used

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

keylegend order when format is used

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;

Accepted Solutions
Solution
‎02-12-2018 10:30 AM
Occasional Contributor
Posts: 19

Re: keylegend order when format is used

I just found the answer, sorting the file first did the trick!

View solution in original post


All Replies
Solution
‎02-12-2018 10:30 AM
Occasional Contributor
Posts: 19

Re: keylegend order when format is used

I just found the answer, sorting the file first did the trick!
☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 76 views
  • 2 likes
  • 1 in conversation