Data visualization with SAS programming

gchart g100 percent and PDF

Reply
Regular Contributor
Regular Contributor
Posts: 156

gchart g100 percent and PDF

Dear all,

I have a proc gchart with g100 where I display the percentage of each bar on top of it. This works fine in HTML but not in PDF. In PDF the percentage on top of the bars is simply missing.

Here's my code:

proc gchart data=work.mydata;
vbar myfield1 / group=mygroupfield type=percent percent g100 freq=myfield2;
run;


Best regards
Eva
SAS Employee
Posts: 967

Re: gchart g100 percent and PDF

I suspect that the pdf is generating the bars a little narrower than your html plot, and there is not enough room for the labels. Are you seeing a "Warning" in your log, such as ...

WARNING: The VBAR/VBAR3D chart for myfield1 could not be labeled because the labels are wider than the bars.

I don't have your data, but I created some mock-up data, and I was able to reproduce the problem (and a fix). The code below seems to work ok, once I added the "width=12" for the bars (depending on how many bars you have, etc, you might have to adjust the width to suit your data)...

-----

%let name=plt038;

data mydata;
input mygroupfield $ 1-6 myfield1 $ 8 myfield2;
datalines;
Group1 a 5
Group1 b 7
Group2 a 6
Group2 b 7
run;


GOPTIONS DEVICE=pdf;
options nodate nonumber;

ODS LISTING CLOSE;
ODS pdf file="&name..pdf" startpage=no;

proc gchart data=mydata;
vbar myfield1 / group=mygroupfield type=percent percent g100 freq=myfield2 width=12;
run;

quit;
ODS PDF CLOSE;
ODS LISTING; Message was edited by: Robert Allison @ SAS
Regular Contributor
Regular Contributor
Posts: 156

Re: gchart g100 percent and PDF

Dear Robert Allison,

from tho look of it it could be that the bars are too narrow. I tried applying width but it didn't work until I used

options papersize=a3;

as well. There was simply not enough room for the graph.

Seem like most pdf problems are solved with width and the like...

Eva
Ask a Question
Discussion stats
  • 2 replies
  • 583 views
  • 0 likes
  • 2 in conversation