BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Kabuto
Obsidian | Level 7

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:

FreqPlot2.png 

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:

FreqPlot3.png

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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."

View solution in original post

1 REPLY 1
FreelanceReinh
Jade | Level 19

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."

sas-innovate-white.png

Our biggest data and AI event of the year.

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.

 

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1052 views
  • 2 likes
  • 2 in conversation