This is a continuation of my GTL Box plot learning curve 🙂 I have Win64 SAS 9.4 M2. Working with the code, below, I can easily get either zero or multiple reference line(s) to display. For example, use _REFLINES="0,9" in the code, below, instead of _REFLINES="100". But I cannot get exactly 1 reference line, e.g., 100, to conditionally appear. I am trying to: Use the Y= options with COLN() function as documented here. Use conditional template language as documented here, aware of the implied EVAL() for the IF statement. Conditionally handle zero, 1, or several reference lines without warnings. "zero" and "several" work as expected! Specifying exactly 1 reference line does not work, and seems to fail because the EVAL(LENGTH(_REFLINES)) return value is missing when _REFLINES contains only digits. Note that I have printed the result of this evaluation in the graph title. Without a proper result from eval(length()), it's hard to program around using COLN() or a single value. I've tried searching these communities, as well as SAS Notes. Notable behavior, the same whether I use LENGTH() or LENGTHC(): EVAL(LENGTH(_REFLINES)) is missing, zero-length, for _REFLINES="100". Check the title text. _REFLINES="100" works as expected with COLN(), if I remove the conditional code IF EVAL(LENGTH(_REFLINES) > 0) and ENDIF;. Use _REFLINES="100 a" in the code, below, instead of _REFLINES="100". and I magically get the 100 line, a correct length of 5, and no syntax warning or error (but COLN() does not like "100,a"). Use _REFLINES="100 " (trailing blanks) in the code, below, and change LENGTH() to LENGTHC() which should not strip trailing blanks, but the single reference line is still omitted, and the length() in the title is still null. _REFLINES="100 110" produces errors, just to confirm that COLN() expects comma-delimited values. Are there some known problems with EVAL(LENGTH(...)) or fixes in SAS 9.4 after M2? Must the string to test include some non-digit, non-space character (a bit unexpected to me)? Here's the play code, and thanks for any advice or alternate approach: proc template;
define statgraph xalignedstats;
dynamic _GRP _CAT _MEASURE _REFLINES;
begingraph / border=false dataskin=none;
entrytitle 'Check result of eval(length(_REFLINES)) [' EVAL(LENGTH(_REFLINES)) ']';
layout overlay / walldisplay=none xaxisopts=(discreteopts=(tickvaluefitpolicy=split));
boxplot x=_CAT y=_MEASURE / group=_GRP groupdisplay=cluster;
IF (length(_REFLINES) > 0)
referenceline y=eval(coln(_REFLINES)) / lineattrs=(color=red);
ENDIF;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.heart template=xalignedstats;
dynamic
_GRP ='bp_status'
_CAT ='smoking_status'
_MEASURE ='diastolic'
_REFLINES="100"
;
run;
... View more