BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
1239
Calcite | Level 5

Hi,

The below sample SAS proc sgplot output is saved in the zip package which contains .html and .gif output. I want to the below output in .pdf file.

I tried with ods pdf but color attributes will not displayed and output will be in black and white if ods pdf is used. The requirement is to get the .gif quality output in .pdf file.

I have nearly 50 files to be generated and manually converting .gif to .pdf is time consuming.

If output is achieved with any other proc procedure with .pdf output file is fine I am only concerned with color output quality with .pdf file.

I am also fine If I get the SAS Macro code to convert .gif file to .pdf with same quality.

Please help me in achieving the requirement. Thanks in Advance.

goptions reset = all;

ods listing close;

  goptions dev=cgm;

  ods package open;

  ods package(foo) open;

  ods html package(foo) file="Mean_Graph.html" newfile=output style=styles.statistical;

  ods graphics / reset width=800px height=400px imagefmt=gif;                                                                           

proc sgplot data=tbl_mean noautolegend;                                                                                                

   scatter x=visit y=avg / datalabel = n yerrorlower=lower                                                                                          

                           yerrorupper=upper

    markerattrs=(color=blue symbol=CircleFilled) ;                                                              

   series x=visit y=avg / lineattrs=(color=blue pattern=2);

TITLE j=c h = 1.5  "Mean Graph";

run;                                                                                                                                  

quit;

  ods html close;

  ods package add file="test.sas" mimetype="text/plain" path="c:\temp\";

  ods package(foo) add file="test.sas" mimetype="text/plain" path="c:\temp\";

  ods package(foo) publish archive properties(archive_name="Mean_Graph.zip" archive_path="c:\temp\");

  ods package(foo) close clear;

  ods package close clear;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ


Hi:

  What STYLE template created your SGPLOT.gif file? That same style template has to be in effect when you use ODS PDF. So, for example, you would change STYLE=PRINTER to STYLE=LISTING or STYLE=HTMLBLUE or STYLE=EGDEFAULT or whichever style you had active when you created SGPLOT.GIF file.

If I use STYLE=HTMLBLUE on a sample SGPLOT using SASHELP.CLASSFIT, I do get RED lines such as you show in your SGPLOT.GIF. If I use STYLES.PRINTER, then I get gray lines. I'd suggest that you change your style to HTMLBLUE.

  If you change your style to HTMLBLUE and the lines are not RED in your PDF file, then you might want to work with Tech Support on this issue.  Code and results shown in screen shot. As you can see, my STYLE= option is set to HTMLBLUE.

cynthia


use_htmlblue.png

View solution in original post

5 REPLIES 5
ballardw
Super User

Did you try specifying the same STYLE as used by HTML output when creating the PDF in your previous trials? Each of the ODS outputs HTML, RTF and PDF have different defaults which result in different colors. Add a STYLE= to each output with the same style name and you are more likely to get desired results.

Cynthia_sas
SAS Super FREQ

Hi: This code worked for me to make a package with 3 PDF files. I created 1 graph for each procedure because of the newfile=output option -- so the first file was named My_Graph.pdf, the second output was named My_Graph1.pdf and the third output was named My_Graph2.pdf. Whatever style you specify on the STYLE= option will be the style that is used for your output. STYLE=STATISTICAL has a lightly colored background for the output. But, for PDF, I generally pick white background styles, like STYLE=PRINTER or STYLE=SASWEB. Since you have ODS LISTING CLOSE, the only destination that is being used in the OP example is the ODS HTML output, which is being controlled by STYLE=STYLES.STATISTICAL (in the posted example -- I used PRINTER style).

  The GOPTIONS DEVICE=CGM is ignored by ODS GRAPHICS. Also, the GIF file is created only by ODS HTML -- I was under the impression that the OP wanted to get PDF outputs instead of HTML outputs, because of the statement that the OP did not want to have to manually convert the GIF files to PDF format. I think that in 9.2, PDF used the PNG image format by default. In 9.3, PDF may use the SVG format by default. I think that both of those formats are probably superior to GIF format. But the OP would have to test that or work with Tech Support if there are still quality issues with the PDF default. Since translation is taking place from the default to internal PDF format, that may require some more investigation to get the best quality.

Here's some doc on the topic of ODS GRAPHICS and destinations:

http://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_odsgraph_sec...

and

http://support.sas.com/documentation/cdl/en/statug/63962/HTML/default/viewer.htm#statug_odsgraph_sec...

and

http://support.sas.com/documentation/cdl/en/grstatproc/62603/HTML/default/viewer.htm#a003200193.htm (9.2 doc, but has a nice explanation of the major differences in a table)

and

http://support.sas.com/documentation/cdl/en/grstatug/63302/HTML/default/viewer.htm#p0uj2mdj2xunoen1h...

  Also, GOPTIONS have no impact on ODS GRAPHICS, so I deleted those statements. Screenshot of my zip file contents is attached. As you can see in my screenshot, there are only the 3 PDF files, plus the extra package information.

cynthia

options nodate nonumber;

ods listing close;

  ods package open;

  ods package(foo) open;

  ods pdf package(foo) file="c:\temp\My_Graph.pdf" newfile=output

      style=styles.printer;

  ods graphics / reset width=800px height=400px;                                                                           

proc sgplot data=sashelp.class noautolegend;                                                                                                

   scatter x=age y=height / datalabel =sex                                                                                           

    markerattrs=(color=blue symbol=CircleFilled) ;                                                              

TITLE j=c h = 1.5  "Mean Graph";

run;                                         

     

proc sgplot data=sashelp.shoes noautolegend;

  where region in ('Asia', 'Canada', 'Pacific', 'Africa');

  title 'Shoes';

  vbar region / response=sales datalabel;

run;

  

proc sgplot data=sashelp.heart;

  title 'heart';

  scatter x=systolic y=cholesterol / group=sex;

run;

title;

   

  ods pdf close;


inside_mean_graph_zip.png
1239
Calcite | Level 5

Hi, Cynthia, Thanks for the code. I have replaced proc sgplot with your code and executed but finally in the output file color attributes lost.

I have attached the sample dataset, .pdf output and .gif file for your reference, you can find the difference in both .gif and .pdf output files. I want the .gif file color display quality in .pdf file. Please help me. Thanks in Advance.

options nodate nonumber;

ods listing close;

  ods package open;

  ods package(foo) open;

  ods pdf package(foo) file="c:\temp\My_Graph exp.pdf" newfile=output

      style=styles.printer;

  ods graphics / reset width=800px height=400px;                                                                         

  proc sgplot data=tbl_mean noautolegend;                                                                                              

   scatter x=visit y=avg / datalabel = n yerrorlower=lower                                                                                        

                           yerrorupper=upper

    markerattrs=(color=blue symbol=CircleFilled) ;                                                            

   series x=visit y=avg / lineattrs=(color=blue pattern=2);

TITLE j=c h = 1.5  "Mean Graph";

run;                                                                                                                                

quit;

 

  ods pdf close;


SGPlot.gif
Cynthia_sas
SAS Super FREQ


Hi:

  What STYLE template created your SGPLOT.gif file? That same style template has to be in effect when you use ODS PDF. So, for example, you would change STYLE=PRINTER to STYLE=LISTING or STYLE=HTMLBLUE or STYLE=EGDEFAULT or whichever style you had active when you created SGPLOT.GIF file.

If I use STYLE=HTMLBLUE on a sample SGPLOT using SASHELP.CLASSFIT, I do get RED lines such as you show in your SGPLOT.GIF. If I use STYLES.PRINTER, then I get gray lines. I'd suggest that you change your style to HTMLBLUE.

  If you change your style to HTMLBLUE and the lines are not RED in your PDF file, then you might want to work with Tech Support on this issue.  Code and results shown in screen shot. As you can see, my STYLE= option is set to HTMLBLUE.

cynthia


use_htmlblue.png
1239
Calcite | Level 5

Hi Cynthia, I have used the same style template in ODS PDF which has been used to generate SGPLOT .gif files and finally color attributes working as per the requirement. Thanks a lot for your helpSmiley Happy

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1749 views
  • 0 likes
  • 3 in conversation