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

Hi,

 

I am attempting to create a histogram in SAS using the following data: 

 

data auto;
input IQscore @@;
datalines;
145 139 126 122 125 130 96 110 118 118
101 142 134 124 112 109 134 113 81 113
123 94 100 136 109 131 117 110 127 124
106 124 115 133 116 102 127 117 109 137
117 90 103 114 139 101 122 105 97 89
102 108 110 128 114 112 114 102 82 101
;

proc univariate data=auto noprint;
histogram IQscore/midpoints=(80 to 150 by 10);
run;

 

My issue is that when I run the program, it shows relative frequency of the data instead of the individual counts for the data (e.g. there are 16 counts of data in the interval between 105 and 115, but it showing 16/60(the total number of data)*100 = 26% instead when you examine the y-axis label).

results.jpg

I also need help changing the axis labels. Any tips are appreciated, thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ
/* display raw counts */
proc univariate data=auto noprint;
histogram IQscore/midpoints=(80 to 150 by 10) 
          vscale=count barlabel=count; 
run;

/* display relative percentages */
proc univariate data=auto noprint;
histogram IQscore/midpoints=(80 to 150 by 10) 
          vscale=percent barlabel=percent;
run;

You can display counts or percentages, or even mix and match! Use the VSCALE= and BARLABEL= options to specify your preferences.

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ
/* display raw counts */
proc univariate data=auto noprint;
histogram IQscore/midpoints=(80 to 150 by 10) 
          vscale=count barlabel=count; 
run;

/* display relative percentages */
proc univariate data=auto noprint;
histogram IQscore/midpoints=(80 to 150 by 10) 
          vscale=percent barlabel=percent;
run;

You can display counts or percentages, or even mix and match! Use the VSCALE= and BARLABEL= options to specify your preferences.

PGStats
Opal | Level 21

You will have more control with sgplot:

 

proc sgplot data=auto;
histogram IQScore / binstart=80 binwidth=10 
    datalabel=count datalabelattrs=(size=10) scale=count;
run; 

SGPlot4.png

PG
Fara_I
Fluorite | Level 6

Thanks!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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