BookmarkSubscribeRSS Feed
DR_Majeti
Quartz | Level 8

When I create a histogram through Proc Gchart I observed some values on horizontal scale called (Midpoints).

Anybody please help me how they will get created?  (on any data set)  How those values are calculated?

If we use discrete as a option. it is easy to understand.

Thanks in Advance !!

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

Hi:

  I'd recommend reading about MIDPOINTS in the SAS/GRAPH documentation. My guess is that your chart variable was numeric. For a numeric variable, SAS/GRAPH tries to "help" you by treating a numeric variable as a continuous variable and so it calculates values to represent the bars, which might be good as a first pass on a variable that represented HEIGHT or WEIGHT, but would not be good for a variable such as AGE. AGE truly is discrete, in other words, you want a bar for each unique value of AGE. But, for example, you would NOT want a bar for each unique value of HEIGHT or WEIGHT. So MIDPOINTS is how PROC GCHART avoids making too many bars for numeric variables. When PROC GCHART calculates MIDPOINTS for you, the word "MIDPOINTS" is usually added to the label under the graph. When you use DISCRETE as an option, you should see that the word MIDPOINTS goes away...this shows that you are in control of the bar values through the use of options.

  There are many different ways to specify your own MIDPOINTS for numeric variables (such as HEIGHT or WEIGHT), and they are all documented. But for variables like AGE, the quickest way to use the unique values for the bars is to specify the DISCRETE option on the VBAR statement.

  There are also other ways to create histograms with SAS, depending on what you want. One way is with PROC FREQ. The other way is with the SGPLOT procedure. You will need to have SAS 9.2 or higher to run examples 3 and 4 in the code below.

cynthia

ods html path='c:\temp' (url=none)

         file='two_histo.html' style=analysis;

 

proc gchart data=sashelp.class;

  title '1) Default MIDPOINTS for Numeric Var';

  vbar age;

run;

quit;

 

proc gchart data=sashelp.class;

  title '2) Using the DISCRETE Option';

  vbar age / discrete;

run;

quit;

 

ods graphics on;

proc freq data=sashelp.class;

  title '3) Graphs with PROC FREQ';

  tables age / plots=all;

run;

ods graphics off;

 

proc sgplot data=sashelp.class;

  title '4) Histogram with SGPLOT';

  histogram age;

  density age / type=normal;

  density age / type=kernel;

run;

 

ods html close;

title;

DR_Majeti
Quartz | Level 8

Thanks Cynthia.. I will come on back this after working on whatever you suggested me..

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 639 views
  • 0 likes
  • 2 in conversation