SAS with Panels
Show macro in new tab or Download
This example produces a paneled beeswarm plot. See the SAS Macro example if you are new to beeswarm plots. See the User Guide if you want even more details about the SAS macro.
Prior to calling the macro, first determine appropriate values for RMARKERS= (i.e., how many markers will fit along the response axis) and GMARKERS= (i.e., how many markers will fit along the grouping axis). By default the macro assumes values of 60 and 80. These values work fine for default-sized SGPLOT output. However, for SGPANEL, the appropriate values are quite different.
SAS
*------------------------------------------------------------;
*---------- determine best rmarkers= and gmarkers= ----------;
*------------------------------------------------------------;
data fillpanel;
do panel = 1 to 3;
do x = 0 to 75;
do y = 0 to 35;1
output;
end;
end;
end;
run;
proc sgpanel data=fillpanel;
panelby panel / columns=3;
scatter x=x y=y;
colaxis thresholdmax=0;
rowaxis thresholdmax=0;
run;
1 The values 75 and 35 are arrived at through experimentation. Expect to have to test several values before getting a good fit.
The values 75 and 35 fit nicely here. Larger values would have resulted in dark strips (indicating overlaps). Smaller values would have resulted in light strips (indicating gaps).
The values for RMARKERS= and GMARKERS= now in hand, producing a paneled beeswarm plot is essentially a 3-step process.
- Split the original dataset into smaller panel-specific datasets.
- Pass the panel-specific datasets to the macro one at a time.
- Stack the panel-specific output datasets back together again and send to SGPANEL.