Hello i have the following dataset. What i would like to do is create two overlay histograms by label_category with x_axis being x axis and use y_axis as y axis.
patientID | y_axis | x_axis | label_category |
1 | 51 | 5.2 | 0 |
2 | 30 | 5.4 | 1 |
3 | 98 | 1.2 | 1 |
4 | 93 | 1.7 | 0 |
5 | 17 | 14.1 | 0 |
Here is what I have so far but i am not sure where to add y_axis
proc univariate data=work.data;
class label_category;
var x_axis;
histogram x_axis/
normal overlay
VAXISLABEL = "Volume trend" ;
label label_category= 'Label Category, 1 = yes, 0 = no";
label x_axis= 'Volume trend';
run;
Traditionally, a histogram is a 1-D display. It displays the number of observations for a variable in a set of bins.
It is not clear what the second variable represents. Is it a frequency? That is, does the first observation represent 51 observations, all with X=5.2 and label_category=0? If so, you can add
FREQ y_axis;
to the PROC UNIVARIATE statement.
yes, i need frequency by y_axis and then # of patients who were in that bin. i added 'freq y_axis" not working
proc univariate data=work.data;
class label_category;
var x_axis; freq y_axis;
histogram x_axis/
normal overlay
VAXISLABEL = "Volume trend" ;
label label_category= 'Label Category, 1 = yes, 0 = no";
label x_axis= 'Volume trend';
run;
> I added "freq y_axis" not working.
What does "not working" mean? Is there an error? Do you get a graph but it isn't what you want? The following example creates a graph with two overlayed histograms:
For an overview of how to create comparative histograms in SAS, see "Comparative histograms: Panel and overlay histograms in SAS."
data Have;
input Sex $ Height Freq;
datalines;
M 69.0 3
F 56.5 7
F 65.3 4
F 62.8 5
M 63.5 2
M 57.3 1
F 59.8 8
F 62.5 2
M 62.5 1
M 59.0 2
F 51.3 4
F 64.3 3
F 56.3 7
F 66.5 5
M 72.0 6
M 64.8 2
M 67.0 1
M 57.5 8
M 66.5 4
;
proc univariate data=Have;
class Sex;
histogram Height / overlay;
ods select histogram;
run;
Please post more data. Five observations is not sufficient.
In your program, you are using the label "Volume Trend," so maybe you really want a line plot or a set of bar charts?
Hello, I believe you are on the right path and a few modifications can help you.
Here is a suggestion for you to continue your work:
ods graphics on / width=10in;
ods select HISTOGRAM;
Proc univariate data=work.data ;
var x_axis;
class label_category;
histogram x_axis / overlay normal kernel ;
Label x_axis = 'Volume trend';
Label label_category= 'Label Category, 1 = yes, 0 = no';
run;
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 16. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.