BookmarkSubscribeRSS Feed
roroholic123
Calcite | Level 5

Hello,

 

I am trying to generate a figure displaying the percent distribution of a variable (y-axis) over the number of weeks (x-axis). Here is the code I used:

 

PROC FREQ DATA=sample;
TABLES weeks / plots=FreqPlot(scale=percent);/* Graph the percentage of "weeks" */
TITLE "Figure 1 The Proportional Distribution of weeks";
RUN;

 

The returned graph looks perfect for what I wanted. But my questions are:

1. How to export only the graph? The output also includes a freq table.

2. How to add a legend to this graph?

3. How to change the labels on both axes?

4. How to change the title of this graph? Currently the title is "Distributions of weeks" and I would like to change it to "Figure 1...".

1 REPLY 1
PaigeMiller
Diamond | Level 26

@roroholic123 wrote:

Hello,

 

I am trying to generate a figure displaying the percent distribution of a variable (y-axis) over the number of weeks (x-axis). Here is the code I used:

 

PROC FREQ DATA=sample;
TABLES weeks / plots=FreqPlot(scale=percent);/* Graph the percentage of "weeks" */
TITLE "Figure 1 The Proportional Distribution of weeks";
RUN;

 

The returned graph looks perfect for what I wanted. But my questions are:

1. How to export only the graph? The output also includes a freq table.

2. How to add a legend to this graph?

3. How to change the labels on both axes?

4. How to change the title of this graph? Currently the title is "Distributions of weeks" and I would like to change it to "Figure 1...".


  1. Use ODS to turn off parts of the output you don't want.
    ods exclude onewayfreqs;
  2. What do you mean by "legend"?
  3. The LABEL statement in PROC FREQ will let you change the horizontal axis label. I don't think you can change the vertical axis label (unless you modify a template somewhere)
  4. Change the TITLE statement.
--
Paige Miller

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 3505 views
  • 0 likes
  • 2 in conversation