Need to create multiple distributions using a variable value to filter the data in a loop.
The example below is an attempt to run a frequency distribution (:RESPONSE) - actually a mosaic chart - for each condition. Unfortunately the output is four mosaic charts for the first condition listed ("Mammogram screening"), not a mosaic chart for each condition. Debugging showed it was running the four iterations.
condition = {"Mammogram screening","Treatment for hearing loss","Fix a broken bone","Lung cancer screening"};
n = N Items (condition);
for (i=1, i<=n, i++,
Current Data Table() <<Data Filter(
Mode( Select( 0 ), Include( 1 ) ),
Add Filter(
columns( :name("Question text") ),
Where( :name("Question text") == condition )
)
);
Distribution(
Nominal Distribution(
Column( :RESPONSE ),
Frequencies( 0 ),
Histogram( 0 ),
Mosaic Plot( 1 )
),
SendToReport(
Dispatch(
{"Distributions", "RESPONSE"},
"Distrib Mosaic",
FrameBox,
{Frame Size( 52, 884 ), Left( 0 ), Right( 0 ), Top( 0 ), Bottom( 0 ),
DispatchSeg( MosaicSeg( 1 ), Cell Labeling( "Show Counts" ) )}
)
)
)
);