BookmarkSubscribeRSS Feed
radhikaa4
Calcite | Level 5

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.

 

patientIDy_axisx_axislabel_category
1515.20
2305.41
3981.21
4931.70
51714.10

 

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;

5 REPLIES 5
Rick_SAS
SAS Super FREQ

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.

radhikaa4
Calcite | Level 5

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;

Rick_SAS
SAS Super FREQ

> 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? 

 

 

Rodolfo_Mingoti
Fluorite | Level 6

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;

radhikaa4
Calcite | Level 5
Thank you. Yes that works but I know it typically in histogram, built in frequency % is generated based on the x_axis.



However, I want to choose my own y_axis by x_axis frequency broken down by yes/no colors.


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!
What is ANOVA?

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.

Discussion stats
  • 5 replies
  • 789 views
  • 0 likes
  • 3 in conversation