בשבוע שעבר ראינו כמה דוגמאות לשימוש ב – proc sgplot ליצירת גרף מסוג סדרה (series). סוג הגרף הזה הוא רק אחד מרבים שניתן לייצר בעזרת sgplot. הנה עוד כמה דוגמאות לסוגי גרפים נוספים.
נתחיל עם הגרף המוכר – גרף עמודות:
ods graphics/height=800px;
proc sgplot data=sashelp.class;
vbar age;
run;
הוא יכול להיות גם אופקי, שימושי במיוחד אם התיאורים של כל עמודה הם ארוכים:
proc sgplot data=sashelp.cars;
hbar make/categoryorder=respdesc;
run;
סוג גרף שימוש נוסף הוא גרף הפיזור:
proc sgplot data=sashelp.class;
scatter x=weight y=height/group=sex markerattrs=(symbol=CircleFilled size=10px);
run;
כמובן מכיוון שמדובר ב – SAS אפשר לשלב קצת סטטיסטיקה בגרף:
proc sgplot data=sashelp.class;
reg x=weight y=height/group=sex markerattrs=(symbol=CircleFilled size=10px) clm clmtransparency=0.1;
run;
אפשר גם להציג את משוואת הרגרסיה עצמה על הגרף אם רוצים אבל, לצערי, זה דורש קצת יותר קוד ממה שזה אמור.
גרף נוסף, שלא משתמשים בו מספיק לדעתי, הוא ה - box plot שמאפשר לקבל המון מידע במעט מקום. גם הוא זמין בגירסא אופקית ובגירסא האנכית הקלאסית:
proc sgplot data=sashelp.cars;
hbox msrp/category=make;
run;
לסוגי גרפים רבים ניתן להוסיף גם קווי ייחוס על כל אחד מהצירים:
proc sgplot data=sashelp.class;
scatter x=weight y=height/group=sex markerattrs=(symbol=CircleFilled size=10px);
refline 100/ axis=x lineattrs=(thickness=3px);
refline 65/ axis=y lineattrs=(thickness=3px);
run;
חגי