COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Histogram with gplot

• Email
• Follow

```Hello

I would like to create a histogram with several variables plotted
against the horizontal variable. Now, this can be done using gplot and
a wide needle; something like the following:

symbol1 i=needle v=none w=32 color=red;
symbol2 i=needle v=none w=32 color=blue;

proc gplot data= bot;
plot verticalvar*horizontalvar=groupvar;
run;

However, when running this code, the automatically created horizontal
line at 0 on the vertical axis takes the width specified for symbol1.
With, say, w=32, the graph looks rather unattractive. The only way I
could see how to circumvent this, is to create dummy observations with
value 0, let symbol1 map to those, and set symbol1 w=1. However, is
there a cleaner way to code a thin horizontal line?

Thanks  for any input.
Soeren Hvidkjaer
```
 0
Reply hvidkjaer (4) 5/26/2010 9:07:44 AM

See related articles to this posting

```On May 26, 11:07=A0am, "hvidkj...@gmail.com" <hvidkj...@gmail.com>
wrote:
> Hello
>
> I would like to create a histogram with several variables plotted
> against the horizontal variable. Now, this can be done using gplot and
> a wide needle; something like the following:
>
> =A0 =A0 symbol1 i=3Dneedle v=3Dnone w=3D32 color=3Dred;
> =A0 =A0 symbol2 i=3Dneedle v=3Dnone w=3D32 color=3Dblue;
>
> =A0 =A0 proc gplot data=3D bot;
> =A0 =A0 =A0 =A0 plot verticalvar*horizontalvar=3Dgroupvar;
> =A0 =A0 run;
>
> However, when running this code, the automatically created horizontal
> line at 0 on the vertical axis takes the width specified for symbol1.
> With, say, w=3D32, the graph looks rather unattractive. The only way I
> could see how to circumvent this, is to create dummy observations with
> value 0, let symbol1 map to those, and set symbol1 w=3D1. However, is
> there a cleaner way to code a thin horizontal line?
>
> Thanks =A0for any input.
> Soeren Hvidkjaer

Actually, my understanding of the functionality was not correct.
Consider the following example:

data a;
do tmpvar =3D 1 to 10;
do groupvar =3D -1 to 1;
hvar =3D tmpvar+groupvar*.1;
vvar =3D ranuni(0)-.5;
output;
end;
end;
run;

symbol1 i=3Dneedle v=3Dnone w=3D1 color=3Dred;
symbol2 i=3Dneedle v=3Dnone w=3D1 color=3Dred;
symbol3 i=3Dneedle v=3Dnone w=3D32 color=3Dblue;

options orientation =3D landscape
papersize =3D letter;

ods trace on;

ods select Gplot;

ods pdf file=3D"histogram.pdf";
proc gplot data=3D a;
plot vvar*hvar=3Dgroupvar;
run;
quit;
ods pdf close;

Having run this with different widths in the symbol statements, it
seems that the only combination that yields a thin horizontal line at
zero is the one with w=3D1 in symbol1 and symbol2. For instance,

symbol1 i=3Dneedle v=3Dnone w=3D1 color=3Dred;
symbol2 i=3Dneedle v=3Dnone w=3D32 color=3Dred;
symbol3 i=3Dneedle v=3Dnone w=3D32 color=3Dblue;

or

symbol1 i=3Dneedle v=3Dnone w=3D1 color=3Dred;
symbol2 i=3Dneedle v=3Dnone w=3D32 color=3Dred;
symbol3 i=3Dneedle v=3Dnone w=3D1 color=3Dblue;

would yield a thick horizontal line. Any insight into the mapping of
needle width into horizontal line width would be much appreciated.

Thanks
Soeren
```
 0

1 Replies
1464 Views

Similar Articles

12/7/2013 2:49:30 AM
page loaded in 25147 ms. (0)

Similar Artilces:

Bug in GPlot?
Hi folks, Has anyone run into a problem using regression lines in PROC GPLOT along = with variables that have names longer than 8 characters? Using SAS 8.2 = under Window 2000, I get a read access violation. See extract from = sample log below. If I switch to variable names of 8 characters or = less, then everything works ok. Also works ok if I don't specify the = regeqn option on the plot statement. Appears that the regeqn option = hasn't been updated to handle long variable names. :-( Thanks. s/KAM 577 symbol1 i=3DRL v=3D"-"; 578 579 580 data plot; Marker1Elev=3D1; Marker2Elev=3D1; output; = Marker1Elev=3D2; Marker2Elev=3D2; output; run; NOTE: The data set WORK.PLOT has 2 observations and 2 variables. NOTE: DATA statement used: real time 0.01 seconds cpu time 0.01 seconds 581 582 proc gplot data=3Dplot; 583 plot Marker2Elev*Marker1Elev / regeqn; 584 run; ERROR: Read Access Violation In Task ( GPLOT ] Exception occurred at (5EC527FC) Task Traceback NOTE: The SAS System stopped processing this step because of errors. NOTE: There were 2 observations read from the data set WORK.PLOT. NOTE: PROCEDURE GPLOT used: real time 0.04 seconds cpu time 0.04

gplot and macro
&where (MT=catalog); RUN; quit; PROC datasets NOLIST; DELETE O&where (MT=catalog); RUN; quit; proc gplot data=&dsname gout=&where_&WAF; /*I JUST WANT THE OUTPUT CATALOGS W24_4, W24_8, W24_20, W25_4, W25_8, W25_20 to be created I can handle the rest*/ plot Ids * Vds = VGS; by x y waferno transistor; where waferno=&waf transistor="&where"; run; quit; PROC catalog CAT=&where&WAF; CONTENTS OUT=c; RUN; proc greplay igout=&where&WAF gout=work.O&where&WAF TC=testdim.templt template=U3m3l3 NOFS; treplay 1:GPLOT1 2:GPLOT3 3:GPLOT6 4:GPLOT 5:GPLOT5 6:GPLOT8 7:GPLOT2 8 :GPLOT4 9:GPLOT7; run; QUIT; %let FOLDER=G:\webcurves\&lotno\&lotno_&where_&WAF; options noxwait noxsync; data _NULL_; /*CREATES A WINDOWS FOLDER*/ length FOLDER \$400; FOLDER="&FOLDER"; rc=filename('_', FOLDER); DIRID=dopen('_'); if DIRID =0 then do; command='cd "G:\webcurves\"'; call system(command); x mkdir "&folder"; end; else do; put '

proc gplot
hi all, I have a situation in which I have around 200 plots to print to the output however I want only 2 graphs per page. Is there a way to do this. I read the documentation however I did not find any option that does this. thanks in advance Nishant Dholakia wrote: > hi all, > I have a situation in which I have around 200 plots to print to the > output however I want only 2 graphs per page. Is there a way to do > this. I read the documentation however I did not find any option that > does this. Proc GREPLAY is one tool to print more than one plot on a page. Learn about the TR

Proc gplot annotate question
Hi All, I hope everyone is doing gr8. It's been a while since I've posted any question on the group. However is my question and I'm sure that you guys would be able to help me out. I've created a box plot for the distribution of lab analytes by time and treatment. Now I've all together 3 treatments and there around 7 visits (Baseline, Month 1, Month 2, Month 3, Month 4,Discontinued, end of study). I've to display the number of subjects at each visit underneath of the plot in the form of a legend. Here's in an example of how I'd like that to be displayed. Can someone please help me with how to create the annotate dataset so that I can pass it to proc gplot and get this done. Number of subjects at visit Drug A 60 59 58 58 58 20 38 Drug B 40 40 40 40 38 10 28 Drug C 50 50 50 50 43 10 33 Thanks in advance!!

Proc gplot! #2
Hi All, i have a question regarding axis statement for proc glpot, actually i'm plotting a graph value vs. time and time variable is formatted by format 5.2 , now the problem is on x-axis the time value has same format even though in order statement i have specified range from 0 to 80 by 10. Is there any option to represent these values on x axis without that format. Thanks in advance, Tarak --------------------------------- Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. Yes, assign a format of your choice in PROC GPLOT. That what you have in the ORDER is the numeric contents, that what is in the FORMAT ist that what you see. If you need the value with two formats, I'd use a second, independant variable, assign the values from TIME and format it how you want to see it. Gerhard On Tue, 19 Jun 2007 08:11:28 -0700, Tarak Patel <tarak81patel@YAHOO.COM> wrote: >Hi All, > >i have a question regarding axis statement for proc glpot, > >actually i'm plotting a graph value vs. time and time variable is formatted by format 5.2 , now the problem is on x-axis the time value has same

Gplot and long axis labels
I'm having problems with long vertical axis labels in gplot. Below is a program (v9.1.2 on winXP) where I try to rotate the label - it doesn't work. I understand I could also split up the text like axis1 label=('a very' j=c 'long' j=c etc but this is pretty messy. Is there a neater way of handling long axis labels? goptions reset=all device=win rotate=portrait ftext="Times New Roman" htext=12pt ftitle="Times New Roman" htitle=12pt htext=12pt hsize=12cm vsize=15cm; data temp; do x=1 to 3; y=x**2; output; end; axis1 label=('a very long vertical axis label' angle=90); proc gplot; plot y*x/vaxis=axis1; run;

simple proc gplot question
=0FEEDx; data tenz; do z = 1 to 10; do x = 1 to 10; y = z + 0.5*ranuni(&seed); output; end; end; run; goptions reset=all ftext='Arial' htext=18pt i=join; symbol1 v=dot; ods listing; proc gplot data=tenz; title "A category Z plot"; plot y * x = z; run; ----------------- Richard A. DeVenezia http://www.devenezia.com/

Gplot vertical dotted lines?
I'm trying to do a connected line graph where the values on the x-axis are names (strings). The graph works so far. However, I'd like to add two things: 1. have a very light dotted line parallel to the Y-axis at each tick on the X. 2. Place a numeric value underneith each label on the X-axis. The numeric value is in the dataset record for each name. Any suggestions?

Proc Gplot (notes and warnings)
This is my Proc Gplot code and using this code I am getting couple of warnings and green notes How to avoid them. And one simple question this is code I am using from other study not sure weather the resultant Graph is right or wrong , How do we validate the graph results ?? PROC GCHART DATA = final ; by visitnum ; format trtgrp trt. visitnum vst.; VBAR cp/ discrete SUMVAR = pctchange group=trtgrp gspace=2 space=3 width=3 nozero vref=0 LREF=2 patternid=group... expect, not whether you had selected the appropriate analysis to do whatever it is that you're trying to accomplish. Art ------- On Thu, 24 Dec 2009 09:15:00 -0800, SAS_learner <proccontents@GMAIL.COM> wrote: >This is my Proc Gplot code and using this code I am getting couple of >warnings and green notes How to avoid them. >And one simple question this is code I am using from other study not sure >weather the resultant Graph is right or wrong , How do we validate the graph >results ?? > > >PROC GCHART DATA = final ; >by visitnum ; >format

GOPTIONS
How does one change the thickness of the dot? I play around with different valules of width ranging from 1 to 100, but I see no change? GOPTIONS TARGETDEVICE=JPEG ROTATE=LANDSCAPE; SYMBOL1 I=none width= 1 V=DOT COLOR=red; Use height= instead Width is for the width of lines (you have none), height is for symbol size.