48 %local dsid grouptype xvalues xvalues2;
 
   51 %let dsid=%sysfunc(open(&data));
 
   52 %
if &dsid=0 %then %
do; 
 
   53    %put ERROR: boxplot: Data 
set &data does not exist; 
 
   57 %
if "&x"=
"" %then %
do;
 
   58    %put ERROR: boxplot: X variable not specified; 
 
   59    %let dsid=%sysfunc(close(&dsid));
 
   63 %
if %sysfunc(varnum(&dsid,&x))=0 %then %
do;
 
   64    %put ERROR: boxplot: Variable &x does not exist in data 
set &data ; 
 
   65    %let dsid=%sysfunc(close(&dsid));
 
   70 %
if %sysfunc(vartype(&dsid,%sysfunc(varnum(&dsid,&x)))) NE N %then %do;
 
   71    %put ERROR: boxplot: Variable &x in data set &data must be numeric; 
 
   72    %let dsid=%sysfunc(close(&dsid));
 
   77    select distinct &x into :xvalues separated by '" "' from &data;
 
   78    select distinct &x into :xvalues2 separated by ' ' from &data;
 
   81 %if "&y"="" %then %do;
 
   82    %put ERROR: boxplot: Y variable not specified; 
 
   83    %let dsid=%sysfunc(close(&dsid));
 
   87 %if %sysfunc(varnum(&dsid,&y))=0 %then %do;
 
   88    %put ERROR: boxplot: Variable &y does not exist in data set &data ; 
 
   89    %let dsid=%sysfunc(close(&dsid));
 
   93 %if %sysfunc(vartype(&dsid,%sysfunc(varnum(&dsid,&y)))) NE N %then %do;
 
   94    %put ERROR: boxplot: Variable &y in data set &data must be numeric; 
 
   95    %let dsid=%sysfunc(close(&dsid));
 
   99 %if "&group"="" %then %do;
 
  100    %put ERROR: boxplot: Group variable must be specified; 
 
  101    %let dsid=%sysfunc(close(&dsid));
 
  105 %if %sysfunc(varnum(&dsid,&group))=0 %then %do;
 
  106    %put ERROR: boxplot: Variable &group does not exist in data set &data ; 
 
  107    %let dsid=%sysfunc(close(&dsid));
 
  111 %let grouptype=%sysfunc(vartype(&dsid,%sysfunc(varnum(&dsid,&group))));
 
  114    select count(distinct &group) into :count from &data;
 
  115    select min(&group) into :lower from &data;
 
  117 %if &lower=. %then %do; 
 
  118    %put ERROR: boxplot: Missing values in group variable are not allowed; 
 
  120    %*** This is code not covered by any testcase and left intetionally here to ***;
 
  121    %*** demonstrate the functionality of the test coverage                     ***;
 
  122    proc sql noprint; drop table &d_1; quit;
 
  124 %if &count NE 2 %then %do;
 
  125    %put ERROR: boxplot: Variable &group must have exactly two values; 
 
  129 %let dsid=%sysfunc(close(&dsid));
 
  137    create table &d_1 as select distinct &x from &data;
 
  143    if _n_>1 then output; 
 
  146 %local xdiff1 xdiff2 xmin xmax misscount;
 
  148    select mean(&x), min(&x) into :xdiff1, :xdiff2 from &d_1;
 
  149    select min(&x), max(&x) into :xmin, :xmax from &data;
 
  151    select count(*) into :misscount from &data where &x is missing;
 
  153 %if &xdiff1=. %then %do;
 
  154    %put ERROR: boxplot: x variable must have at least two values;
 
  155    proc sql noprint; drop table &d_1; quit;
 
  158 %if &misscount>0 %then %do; 
 
  159    %put ERROR: boxplot: Missing values in x variable are not allowed;
 
  160    proc sql noprint; drop table &d_1; quit;
 
  164 %let xmin=%sysevalf(&xmin-&xdiff1);
 
  165 %let xmax=%sysevalf(&xmax+&xdiff1);
 
  168 %if &xdiff1 ne &xdiff2 %then %do; 
 
  169    %put ERROR: boxplot: Values of x variable are not equidistant;
 
  170    proc sql noprint; drop table &d_1; quit;
 
  177    SET &data (KEEP=&x &y &group);
 
  178    IF &group = %if &grouptype=N %then &lower; %else "&lower"; THEN DO;
 
  179       &x = &x - 0.11*&xdiff1;
 
  182       &x = &x + 0.11*&xdiff1;
 
  185 %let d_plot=&syslast;
 
  188 GOPTIONS FTEXT="Helvetica" HTEXT=12pt hsize=16cm vsize=16cm;
 
  189 SYMBOL1 WIDTH = 3 BWIDTH = 3 COLOR = gray  LINE = 2 VALUE = none INTERPOL = BOXJT00 MODE = include;
 
  190 SYMBOL2 WIDTH = 3 BWIDTH = 3 COLOR = black LINE = 1 VALUE = none INTERPOL = BOXJT00 MODE = include;
 
  191 AXIS1 LABEL=(ANGLE=90) MINOR=none;
 
  192 AXIS2 ORDER=(&xmin &xvalues2 &xmax) VALUE=(" " "&xvalues" " ") MINOR=none;
 
  195 ODS PDF FILE="&report";
 
  197 PROC GPLOT DATA=&d_plot;
 
  198    PLOT &y * &x = &group / VAXIS=Axis1 HAXIS=Axis2 LEGEND=Legend1 NOFRAME;