- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Inspired by Rick Wicklin who created a nice mosaic plot by using airline crash data, I wonder if the percentage #s from "proc freq" can be annotated on the mosiac plot. That's would be easy to present in the idea of "numbers within graph".
Hope some SAS guru here can help me get the desired outcome.
Below is the short version of Rick's SAS code, The attached you'll find raw data in CSV format and PPT file including current result and desired result.
Thanks,
Ethan
PROC IMPORT OUT= WORK.CrashRaw
/* CHANGE the next line to point to the location of the FlightRisk.csv file */
DATAFILE= "h:\temp\FlightRisk.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=3;
RUN;
/* Do some data cleansing */
data Crash;
label Phase="Flight Phase" Cause="Cause of Crash";
set CrashRaw(rename=(cause=LongCause meta=Cause));
Year = Year(Date);
if Phase="ap" | substr(upcase(Phase),1,8)="APPROACH" | Phase="Landing" then Phase="landing";
if Phase="grounded" then Phase="standing";
if Phase="initial takeo" | Phase="take off" | Phase="Takeoff" | Phase="takeoff" |Phase="initial_climb" then Phase="take-off";
if Phase="en_route" then Phase="en route";
if Cause="human_error" then Cause="human error";
/* order by frequency */
if Phase="landing" then PhaseN=1;
else if Phase="en route" then PhaseN=2;
else if Phase="take-off" then PhaseN=3;
else if Phase="standing" then PhaseN=4;
else if Phase="unknown" then PhaseN=5;
if Cause="criminal" then CauseN=1;
else if Cause="unknown" then CauseN=2;
else if Cause="mechanical" then CauseN=3;
else if Cause="weather" then CauseN=4;
else if Cause="human error" then CauseN=5;
run;
ods _ALL_ close;
ods listing gpath="H:\Temp" image_dpi=300;
ods graphics on / width=600px height=600px reset=index outputfmt=PNG imagename="crash_mosiac" ;
proc freq data=Crash order=data;
tables Cause*Phase / nocum norow nocol
plots=(mosaic(square));
run;
ods graphics off;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Many of the plots associated with analysis procedures have vary limited options. You may have to summarize the data and go to Graphic Template Language and a MOSAICPLOTPARM block of code to control appearances.