turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Proc Gchart (Want to know about Backend Process)

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-02-2013 02:20 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-02-2013 10:57 AM

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;**

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-05-2013 03:48 AM

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