Hi,
I have a table with many columns. one is a binary variable with 0,1 and lables 0=No, 1=Yes.
Another is a formula column based on several others which is categorical with the numbers 0-5.
I would like to create a bar graph with the categorical column on the x axis and the percentage of yes in each category as the y axis.
I could obtain this data by splitting the table using these two columns (split by = the categorical column and split column= binary column) and then get the distribution of all columns (=original categories), and look at the prob of Yes.
but how do I get this in a bar graph?
this is a pic of the spited data:
and this is a pic of the kind of graph i would like to create:
TIA
This can be accomplished fairly simply using
Analyze==>Tabulate
and then graphing the data from the resulting table
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" ) ) )
);
This can be accomplished fairly simply using
Analyze==>Tabulate
and then graphing the data from the resulting table
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" ) ) )
);