The reality is that both the UWL and LWL charts are failing. You just don't see the issue in the UWL chart. It appears that when you specify an Add Ref Line to a chart when the value to chart is a missing value, ".", the code stops working from that point on for the chart. In the case of the UWL chart, it has listed out all of the reference line you want to be displayed, before the code stops working when it runs into the missing value for the LWL reference line. However, in the LWL chart, the UWL reference line is attemped before the LWL reference line, and the code stops working when it finds the missing value for the UWL reference line. Several different ways of working around this are possing, below is one way to handle this
Names Default To Here( 1 );
dt = Current Data Table();
// Get all of the by values, since separate code will have to be added for each
Summarize( dt, byVals = by( :sex ) );
// Generate the Plot code
op = Overlay Plot(
X( :height ),
Y( :weight ),
by( :sex ),
SendToReport(
Dispatch(
{},
"101",
ScaleBox,
{Label Row( Label Orientation( "Vertical" ) )}
)
)
);
For( i = 1, i <= N Items( byVals ), i++,
// Get the LCL and UCL values for this by group. UWL is only for F and LWL is for M
UCL = :UAL[(dt << get rows where( :sex == byVals[i] ))[1]];
LCL = :LAL[(dt << get rows where( :sex == byVals[i] ))[1]];
UWL = :UWarnL[(dt << get rows where( :sex == byVals[i] ))[1]];
LWL = :LWarnL[(dt << get rows where( :sex == byVals[i] ))[1]];
show(byvals[i],ucl,lcl,uwl,lwl);
// Make sure the UCL and LCL values are displayed
chartMin = Min( :weight[dt << get rows where( :sex == byVals[i])]);
chartMax = Max( :weight[dt << get rows where( :sex == byVals[i])]);
If(LCL < chartMin, chartMin = LCL );
If(UCL > chartMax, chartMax = UCL );
chartRange5% = (chartMax - ChartMin)/20;
chartMin = chartMin - chartRange5%;
chartMax = chartMax + chartRange5%;
// Generate the code to produce the LCL and UCL reference lines
Eval(
Substitute(
Expr(
op << SendToByGroup(
{:sex == __byVals__},
Y Axis[1] << {{Min( __min__ ), Max( __max__ ),
Add Ref Line( __UCL__, "Solid", "Medium Dark Red", "UAL", 1 ),
Add Ref Line( __LCL__, "Solid", "Medium Dark Red", "LAL", 1 ),
Add Ref Line( __WLVal__, "dotted", "Medium Dark Red", __WL__, 1 )
}}
)
),
Expr( __byVals__ ), byVals[i],
Expr( __UCL__ ), UCL,
Expr( __LCL__ ), LCL,
Expr( __WLVal__ ), If(isMissing(UWL)==0,UWL,LWL),
Expr( __WL__ ), If(isMissing(UWL)==0,"UWL","LWL"),
Expr( __min__ ), chartMin,
Expr( __max__ ), chartMax
)
);
);
Jim