Anyone have hints for getting clean PDF output from PROC SGPLOT (and similar functions like SGSCATTER)?
When I create a graph and write it to a PDF with ODS, the result looks fine in the sas EG report window but the PDF output gets rasterized to the DPI setting of the PDF so if you zoom into the PDF you can make out pixelation. Additionally, if I don’t define colors/line styles, the output in the PDF will use different colors and styles (lines that were solid in the sas report window become dashed in the PDF).
If I make the same chart with PROC GPLOT, it comes with vectorized text and lines that don’t look like junk when zoomed/printed.
Is there an option I need to change? Some flag I need to set? I’ve tried things like OPTIONS DEVICE=SVG and it doesn’t seem to work. Setting a really high DPI isn’t a very good solution either.
Code Example (but really, this happens on all of the SG* functions with any data/code):
options nonumber orientation=landscape;
ods pdf file='FILENAME.pdf' notoc;
proc sgplot data=shipped;
series x=date y=weighted_price / group=type;
run;
proc gplot data=shipped;
plot weighted_price*date=type;
symbol1 c=blue i=join v=none w=1 l=1;
symbol2 c=red i=join v=none w=1 l=1;
symbol3 c=brown i=join v=none w=1 l=1;
run; ods pdf close;
These produce roughly equivalent graphs in the sas EG results window (except the SGPLOT looks nicer) but when they end up in the pdf, the SGPLOT is rasterized to an image and dropped onto the PDF page while the GPLOT comes out as a lovely vector chart.
EDIT: See solutions I posted below. I didn’t find it to be well documented, but SAS 9.2 did not have very good PDF support. There are a couple of workarounds that are ok for a 1-off chart, but the best solution is to just upgrade to SAS 9.3.
I have finally solved this. There are a few ways that sort of work, and one way that really works.
The “perfect” solution is upgrading to SAS 9.3; SAS 9.2 can’t make the SGPLOT/SGPANEL charts into a vectored PDF. Running the same code in SAS 9.3 produces perfect looking charts.
I found two other partial solutions:
1: In enterprise guide, you can tweak the display settings and if you get everything right, you can print the SAS Report window and use an Adobe PDF printer. This works ok although the output sometimes looks very un-sas.
2:
ods latex file='file.tex' gout='/.../';(set gout= to your output directory). This produces, in unix 9.2 at least, a garbage TeX file that has no line breaks and doesn’t seem to actually reference the charts. It also produces a PostScript file for every chart! You can use this .ps file with Distiller (or TeX) to create decent looking vector charts. They print nicely, although I found the SAS 9.3 PDF to look far better on screen than the .ps from this method.