This can be accomplished fairly simply using
Analyze==>Tabulate
and then graphing the data from the resulting table
![tab.PNG tab.PNG](https://community.jmp.com/t5/image/serverpage/image-id/25972iB16439C064285288/image-dimensions/489x366?v=v2)
- Start with your 2 columns, the one with 0-1 values and the other with your 0-4 values. Both columns need to have a modeling type of Ordinal. I have called the rows, "Intervention" and "Number of Positive Risk Factors".
- Place "intervention as a column grouping variable
- Place "Number of Positive Risk Factors" as a row grouping variable
- Set the statistic as Row %
![tab2.PNG tab2.PNG](https://community.jmp.com/t5/image/serverpage/image-id/25974iC077AD1FAB520BEE/image-dimensions/616x506?v=v2)
- Go to the red triangle and select "Make into Data Table"
![tab3.PNG tab3.PNG](https://community.jmp.com/t5/image/serverpage/image-id/25976i392A0AD2580BCFDE/image-dimensions/646x307?v=v2)
- Change the name of the Column "Row %(1)" to "Rate of Intervention"
![tab4.PNG tab4.PNG](https://community.jmp.com/t5/image/serverpage/image-id/25977i257E142C3791A070/image-size/large?v=v2&px=999)
- Go to Graph Builder and create the graph
- Drag "Number of Positive Risk Factors" to the X axis
- Drag "Rate of Intervention" to the Y axis
- Click on the Bar Graph icon to change the graph to a bar chart
- In the Bar details section on the left side of the window, change the Label to "Label by Value"
Here is a script that produces the above
Names Default to Here(1);
dt=new table("Example",
add rows(400),
new column("Intervention", ordinal, set each value(Random Integer(0,1))),
new column("Number of Positive Risk Factors",ordinal,set each value(Random Integer(0,4)))
);
// Calculate the Statistic
tab = dt << Tabulate(invisible,
Add Table(
Column Table( Grouping Columns( :Intervention ), Statistics( Row % ) ),
Row Table( Grouping Columns( :Number of Positive Risk Factors) )
)
);
dtFinal = tab << make into data table;
// Change Column Name
dtFinal:Name("Row %(1)") << Set Name("Rate of Intervention");
// Create Graph
Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables( X( :Number of Positive Risk Factors ), Y( :Rate of Intervention ) ),
Elements( Bar( X, Y, Legend( 6 ), Label( "Label by Value" ) ) )
);
Jim