Looping distribution with a data filter<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />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() <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" ) )}
)
)
)
);
Re: Looping distribution with a data filterYour solution worked well. Thank you! Rid of data filter and added “by” statement.
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" ) )}
)
), By( :Question text ));
Re: Looping distribution with a data filterhi cdwhite ,
i am not sure what you are trying to do.
perhaps you can just use the By option
Open( "$SAMPLE_DATA/Big Class.jmp" );
Distribution( Continuous Distribution( Column( :height ) ), By( :age ) );
ron