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

Hi,

I produced a histogram with proc sgplot using this code: 

 

proc sgplot data=work.test;
  histogram age_num;
  density age_num;
run;

 

The plot produced is the followed:

SGPlot2.png

As you can see, there are some irregularities for some ages. To validate, I tried to create the same chart using prec freq instead:

 

 

proc freq data=work.test;
table age_num /plots=freqplot;
run;

 

 

The chart is the following, which, as you can see, is very different, since there are no more irregularities.

FreqPlot.png

 

So I wonder: how is this possible? Maybe I do not interpret correctly the output produced by the proc sgplot.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

In the SGPLOT output, there don't appear to be 20 bins in the range 41 and 60 (for example, it's probably true for all 20 unit increments). So you need to modify your SGPLOT code to make sure you have 20 bins for every 20 units on the x-axis.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

In the SGPLOT output, there don't appear to be 20 bins in the range 41 and 60 (for example, it's probably true for all 20 unit increments). So you need to modify your SGPLOT code to make sure you have 20 bins for every 20 units on the x-axis.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1078 views
  • 0 likes
  • 3 in conversation