Kengo Nagashima



gplot procedureを使う

symbol statement の i = box を用いると、箱ひげ図を描くことができます。
多群のグラフを重ねる場合は、y * x = z の形式で指定すればよいです。
標本平均値も表示したい場合は、plot2 statement を利用すると追加できます。

gplot procedureを使って描いた場合

download (gplotbox.sas)

proc datasets lib = work kill; run;
option linesize = 130 pagesize = 9999 mprint;
dm 'log; clear; output; clear';

%let execpath = " ";
%let Path = " ";
%macro setexecpath;
  %let execpath = %sysfunc(getoption(sysin));
  %if %length(&execpath) = 0 %then
    %let execpath = %sysget(sas_execfilepath);
  data _null_;
    do i = length("&execpath") to 1 by -1;
      if substr("&execpath", i, 1) = "\" then do;
        call symput("Path", substr("&execpath", 1, i));
        stop;
      end;
    end;
  run;
%mend setexecpath;
%setexecpath;

data boxplot;
call streaminit(8876542);
do group = 1 to 3;
  do x = 1 to 5;
    do i = 1 to 5;
      y = rand("Normal", (4-group)**2 * x / 10, 0.2);
      output;
end; end; end;
proc sort data = boxplot; by x group;
proc summary data = boxplot;
  var y; by x group;
  output out = summary mean = m;
data boxplot; set boxplot summary;
run;

goptions reset = all;
goptions ftext = 'Times New Roman' ftitle = 'Times New Roman';
goptions hsize = 6 in vsize = 6 in htitle = 1.6 htext = 1.6;
options linesize = 130 pagesize = 9999;

filename grafout "&Path.gplotbox.emf";
goptions device = emf gsfname = grafout gsfmode = replace;

proc gplot data = boxplot;
  plot y * x = group /
    noframe vaxis = axis1 haxis = axis2 legend = legend1;
  plot2 m * x = group / vaxis = axis3 legend = legend2;
  symbol1 i=boxt00   c=cx5ECD22 bwidth=6;
  symbol2 i=boxt00   c=cxFAA55C bwidth=6;
  symbol3 i=boxt00   c=cxE04251 bwidth=6;
  symbol4 v=plus     c=cx5ECD22;
  symbol5 v=square   c=cxFAA55C;
  symbol6 v=triangle c=cxE04251;
  axis1 label = (a=90 "Measurement") minor = none;
  axis2 label = ("Group") offset = (7 7) minor = none;
  axis3 label = none value = none minor = none
    major = none order = -1 to 5 c = white;
  legend1 label = none position = (top left inside)
    across=1 mode = share offset = (3 0) value = (" " " " " ");
  legend2 label = none position = (top left inside)
    across=1 mode = share offset = (3 0);
run; quit;
  

boxplot procedureを使う

できなくはないですが、横軸の値を指定できないので、多分使い物にならないです。
download (boxplot.sas)

boxplot procedureを使って描いた場合

shewhart procedureを使う

私は使ったことがないですが、shewhart procedure というものでも箱ひげ図を描くことが出来るようです。
(参考 SAS Technical News Autumn 2007. Q& A.)

univariate procedure と capability procedure みたいな関係でしょうか?

履歴