I practiced an example from the textbook "The SAS Little Book", the program is:
ODS GRAPHICS ON;
PROC FREQ DATA = bus;
TABLES BusType*OnTimeOrLate / PLOTS=FREQPLOT(TWOWAY = GROUPHORIZONTAL);
RUN;
ODS GRAPHICS OFF;
The plot shows the frequencies of the BusType variable by the OnTimeOrLate variable:
Nonetheless, the textbook shows a frequency plot of the OnTimeOrLate variable by the BusType variable, even though the plot title is still "Distribution of BusType by OnTimeOrLate". Here is a screenshot from the textbook:
I just have no idea why I cannot get the same plot as what the textbook shows. I do not think there is anything wrong with the program. Hopefully anyone can help me figure out.
Hello @Kabuto,
Your code and plot are correct, whereas the graph from the textbook doesn't match its title: A graph "by OnTimeOrLate" must consist of separate parts for different values (or format categories) of OnTimeOrLate, which is obviously not the case there.
Many textbooks contain errors, even some SAS Press titles.
You can reverse the grouping of the plot by switching the variable names in the TABLES statement or by adding the GROUPBY=ROW option in the parentheses after "FREQPLOT."
Hello @Kabuto,
Your code and plot are correct, whereas the graph from the textbook doesn't match its title: A graph "by OnTimeOrLate" must consist of separate parts for different values (or format categories) of OnTimeOrLate, which is obviously not the case there.
Many textbooks contain errors, even some SAS Press titles.
You can reverse the grouping of the plot by switching the variable names in the TABLES statement or by adding the GROUPBY=ROW option in the parentheses after "FREQPLOT."
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.