Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GCHART

Status
Not open for further replies.

Medvedeff

Instructor
Feb 12, 2008
29
US
I believe that this will be my last question...

I have constructed a frequency distribution using gchart. Over top of the graph, I wish to do two things.

1. Draw a verticle bar at a value that I specify.
2. Overlay a thin normal distribution curve constructed out of parameters that I specify (mean and standard deviation).

How do I go about doing this?
 
Ooooh. Now you're getting into the dark arts of SAS programming.
when you say "a vertical bar at a value that I specify", would a reference line fulfill that role for you? Are you using HBAR or VBAR? (There's several different charts you can build through Proc GCHART).
The doco below contains info about setting up a reference line, search for "REF=".

The second item is not so easy. I've done similar things before, but not often, I generally end up doing it in Excel as it's alot easier and more intuitive to set up.
Doing it via SAS involves creating 2 separate graphs/charts, then redrawing them one over the other using Proc GREPLAY.
Here's an example from the SAS support site.

I'll be honest, I find GREPLAY to be quite complex, and I didn't enjoy working with it, but you can do some AMAZING things with it if you get to grips with it. For that reason, I'd say if you are doing this for somethign that's going to be used many times, do it the SAS way. If it's a quickie one off job, load the data into Excel and do it there.

If you want some examples of things people have done using GREPLAY that look cool, check this out:-




Unfortunately, most of the work I do is one off, so I can justify spending a couple of days getting a graph looking nice this way when I could do it in an hour in Excel.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
I am using a VBAR3D. I tried using the ref= option but it seemed to only want to draw the line coming off of the y-axis...or the response axis in your SAS-speak :)

So the overlaying the normalmal seems pretty complicated, so I will just make do without it. Assuming I can get the reference line to work, it will suffice for my purposes
 
OK, yeah, it sounds like the REF= isn't what you want then as it'll be 90 degrees to your bars. If you're effectively saying you want an extra bar on your bar chart at a specific point, then I don't know how to achieve that. You could play around with your MIDPOINTS and MAJORTICKS and MINORTICKS, so you could get a majortick mark on the horizontal axis at the correct point, but I can't see a way of putting a full vertical bar or line there, except perhaps by using GREPLAY.
If you get it, I'd love to see your code.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
I guess I lied...

Again in the GCHART with vbar3d and a frequency distribution:

I want to suppress the automatic labeling of the x-axes values and provide a list of them myself...but I want to do it without changing the number of midpoints that sas produces. here is what I have....

proc gchart data=one.betas;
pattern1 c=red;
vbar3d DPI /
type=freq
cframe=white
levels = 100
space = 0
noframe
coutline=black;
RUN;

I want to keep 100 midpoints, but I want to specify the specific list of values that SAS actually produces as labels.

So instead of having:

.9453 .9454 .9455 .9456 .9457

I want the following values to appear, but maintain the same number of vertical bars in the graph.

.9453 .9455 .9457


I am probably not explaining myself well, but any help would be appreciated.
 
OK.
That looks like you need to play with the tickmarks. The GCHART procedure is pretty well documented, so you should be able to use minor ticks to set that (MINOR=50 might do what you want).
You can play with the AXIS statement to adjust this.

Then reference it in the VBAR3D statement using the GAXIS= option.

I hope this helps...

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
(for ChrisW75)

You said that you just do the overlay graphs in Excel...

I know this is a SAS help Forum, but do you have any tips on setting the parameters (mean and standard deviation) to graph a custom normal distribution in Excel?

Ive been working on something for a couple hours, but something isnt working correctly, beause when I overlay the normal ontop of another graph, it shifts the mean value downward for some reason.

If you have any suggestions, Id really appreciate it.

Thanks
 
I usually calculate the value I want (such as the mean), add it as another column, then right click on the graph and select "Add series" or something like that, then add it as another line. It shouldn't affect the graph that is already there.
Does that help?

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
I can add in another series which will represent the mean value that I am looking for, but the normal overlay is a different story. I might end up just using it as is, with the two vertial bar series, because it shows effectively what Im need (though not exactly what I want :(

Thanks for getting back to me so quickly!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top