Subscribe Bookmark RSS Feed

Looping distribution with a data filter

cdwhite

Community Trekker

Joined:

May 3, 2015

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" ) )}
  )
)
)
);

2 REPLIES
ron_horne

Super User

Joined:

Jun 23, 2011

hi 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

cdwhite

Community Trekker

Joined:

May 3, 2015

Your 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 ));