For some reason, the exact same code written in SAS Base 9.4 and Enterprise Guide 7.1 produce different pdf outputs in terms of quality. While both of them appears perfect inside the program (result window), only Base outputs a similar pdf results. The EG version is about the double size but very blurry.
Do you have any ideas? I find it very weird.
data normal (keep=x); call streaminit(4321); do i=1 to 2000; x=rand("normal")*100; output; end; output; run; title 'Distribution of Blood Pressure'; ods graphics on / border=off; ods pdf file="C:\Users\stan\Dropbox\Documents\base.pdf" notoc dpi=300; proc sgplot data=normal; histogram x / fillattrs=graphdata3 transparency=0.7 binstart=40 binwidth=10; density x / lineattrs=graphdata4; density x / type=kernel lineattrs=graphdata5; keylegend / location=inside position=topright noborder across=2; yaxis grid; run; ods pdf close;
1. Confirm that both are accessing the same version of SAS.
2. Try setting explicit options in ODS graphics statement so the size and antialias options are listed. It's possible that they are set differently in each application.
ODS Graphics options:
I don't know if the DPI affects the graph. I suspect not.
Based on your 400% scaled image, my guess is the EG output PDF file contains an image. This can happen based on your SAS version and content in the graph. Even though you are asking for PDF, the file may contain an embedded image if the graph contents are not supported in vector graphics at the SAS release you (or EG) are using.
For example, at SAS 9.2, all graphs in pdf files were images regardless because we did not have the feature necessary to embed scalable vector graphs. With SAS 9.3, scalable vector graphs were added for PDF and RTF output. However, in some cases where graph uses transparency or gradient colors, the graph is still an image.
With increasing release levels (including maintenance releases), more and more cases can support scalable vector output to PDF. I believe SAS 9.40M3 has a very high level of support for scalable graphics, and only very few cases get flipped to image. You will always see a note in the log when this happens.
It makes so much sense - it also explains why the pdf is twice the size.
Unfortunalty, my research project do not have a license for Base, only EG, so I'm forced to use it. But what irritates me most is that the graph seems perfect in the result window - why is so complicated (say, impossible) to export it so I can use it in my Latex document. In fact, it doens't have to me scalable, only useful in my document.
Options such as WIDTH or HEIGHT can affect resolution when rescaling an image. If the original image is built at 640*480 pixels and you expand the image to appear in a 1900*1600 window then there may not be enough information in the smaller image to get a large image clear. Make the original image as near to the final as you can estimate to minimize rescale effects. If you play with Height and Width you may also want to watch the SCALE option as you may not want everything to resize with the image, such as Title text.
Also results window is likely HTML output and if you are sending the output to a different format then it is just that, different.
The IMAGEFMT can make a different for rescaling as well.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.