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."
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.