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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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