Data visualization with SAS programming

SAS graphic appears blurry in EG but not in Base?

Reply
Occasional Contributor
Posts: 5

SAS graphic appears blurry in EG but not in Base?

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.

 

The different outputs can be seen here.

 

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;
Grand Advisor
Posts: 16,334

Re: SAS graphic appears blurry in EG but not in Base?

Maybe it's the viewer in each? They look identical to me...

 

Occasional Contributor
Posts: 5

Re: SAS graphic appears blurry in EG but not in Base?

It could be the viewer. However, a 400 pct. crop tells the difference I think.

Attachment
Grand Advisor
Posts: 16,334

Re: SAS graphic appears blurry in EG but not in Base?

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:

https://support.sas.com/rnd/app/ODSGraphics/TipSheet_ODSGraphics.pdf

 

I don't know if the DPI affects the graph. I suspect not. 

SAS Super FREQ
Posts: 1,044

Re: SAS graphic appears blurry in EG but not in Base?

[ Edited ]

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.

Occasional Contributor
Posts: 5

Re: SAS graphic appears blurry in EG but not in Base?

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.

 

Hmm.

Grand Advisor
Posts: 16,334

Re: SAS graphic appears blurry in EG but not in Base?

Verify your version of SAS with EG. It may just be settings...or explicitly create a SVG.
Occasional Contributor
Posts: 5

Re: SAS graphic appears blurry in EG but not in Base?

It's 7.1. But how can my settings affect the output?

Grand Advisor
Posts: 9,732

Re: SAS graphic appears blurry in EG but not in Base?

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.

Post a Question
Discussion Stats
  • 8 replies
  • 955 views
  • 4 likes
  • 4 in conversation