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

I get nice colored graphs in the Results Viewer but my outputted pdf file is black and white. (this is an update from last week's post)

code:

ods pdf file="Desktop\plots of sdoc_sc_top10.pdf";
PROC sort data=dst10_math;
by demoid;
run;
proc sgplot data=dst10_math;
by demoid;
styleattrs
datacontrastcolors=(red green blue);
vbar testgrade / response=mathpct34 group=level groupdisplay=cluster datalabel=mathpct34;
xaxis display=(nolabel noline noticks);
yaxis display=(nolabel) values=(0 to 100 by 10) ;
run;
ods pdf close;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Maybe the same solution as almost five years ago 😉

https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-PDF-output-gives-no-color/td-p/309798

 

EDIT: I suspect you have some old programs that turn that option on/off. I would recommend not touching it in future programs because the default is fine.

 

options colorprinting=yes;

View solution in original post

23 REPLIES 23
Reeza
Super User
Is there a specific reason this is in SAS VA and not Graphical Programming?
Reeza
Super User
ods pdf file="Desktop\plots of sdoc_sc_top10.pdf" style=HTMLBlue;
PaigeMiller
Diamond | Level 26

@Reeza wrote:
ods pdf file="Desktop\plots of sdoc_sc_top10.pdf" style=HTMLBlue;

I don't see how this relates to the rest of the thread. Please explain why you showed us this code.

--
Paige Miller
Reeza
Super User
No style is specified in the PDF statement, styles help control the theme and appearance of the graph.
Adding a style, specifically the default should help with ensuring the presentations match between the ODS PDF and ODS HTML results.

FYI - I explained this in the previous post so didn't bother in this one again.
GreggB
Pyrite | Level 9

I updated my code with a style=  and a color= option but with no change.

 

ods pdf file="Desktop\plots of sdoc_sc_top10.pdf" style=HTMLBlue color=full;
PROC sort data=dst10_math;
by demoid;
run;
proc sgplot data=dst10_math;
by demoid;
styleattrs
datacontrastcolors=(red green blue);
vbar testgrade / response=mathpct34 group=level groupdisplay=cluster datalabel=mathpct34;
xaxis display=(nolabel noline noticks);
yaxis display=(nolabel) values=(0 to 100 by 10) ;
run;
ods pdf close;
PaigeMiller
Diamond | Level 26

Since I don't have your data set, I tried this with a different data set, and it works exactly as I expected it to work.

 

ods pdf file="temp.pdf" color=full;
proc sgplot data=sashelp.class;
scatter x=height y=weight/markerattrs=(color=red);
run;
ods pdf close;

When you tried it, were there errors in the log?

--
Paige Miller
GreggB
Pyrite | Level 9
518  ods pdf file="Desktop\plots of sdoc_sc_top10.pdf" style=HTMLBlue color=full;
NOTE: Writing ODS PDF output to DISK destination
      "C:\Users\gbibb\Desktop\plots of sdoc_sc_top10.pdf", printer "PDF".
519  PROC sort data=dst10_math;
520  by demoid;
521  run;

NOTE: Input data set is already sorted, no sorting done.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


522  proc sgplot data=dst10_math;
523  by demoid;
524  styleattrs
525  datacontrastcolors=(red green blue);
526  vbar testgrade / response=mathpct34 group=level groupdisplay=cluster datalabel=mathpct34;
527  xaxis display=(nolabel noline noticks);
528  yaxis display=(nolabel) values=(0 to 100 by 10) ;
529  run;

NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           2.92 seconds
      cpu time            1.45 seconds

NOTE: There were 299 observations read from the data set WORK.DST10_MATH.

530  ods pdf close;
NOTE: ODS PDF printed 17 pages to C:\Users\gbibb\Desktop\plots of sdoc_sc_top10.pdf.
PaigeMiller
Diamond | Level 26

I don't think DATACONTRASTCOLORS works on VBAR plots. Try DATACOLORS=

--
Paige Miller
Reeza
Super User

What happens if you run the following code? 

My bars are grey but they're outlined in the colours identified in the data contrast list. 

 

Version 1 (Results in Demo (4))

ods pdf file='/home/fkhurshed/Demo1/demo.pdf' style=HTMLBlue color=full;

proc sort data=sashelp.cars out=cars;
by origin;
run;


proc sgplot data=cars;
 by origin;
 styleattrs
  datacontrastcolors=(red green blue);
 vbar make / response=cylinders stat=freq group=type groupdisplay=cluster ;
  xaxis display=(nolabel noline noticks);
 *yaxis display=(nolabel) values=(0 to 100 by 10) ;
  run;

ods pdf close;

Version 2 (results in Demo (5))

ods pdf file='/home/fkhurshed/Demo1/demo.pdf' /*style=HTMLBlue*/ color=full;

proc sort data=sashelp.cars out=cars;
by origin;
run;


proc sgplot data=cars;
 by origin;
* styleattrs
  datacontrastcolors=(red green blue);
 vbar make / response=cylinders stat=freq group=type groupdisplay=cluster ;
  xaxis display=(nolabel noline noticks);
 *yaxis display=(nolabel) values=(0 to 100 by 10) ;
  run;

ods pdf close;

Results are attached  - do they match what you're getting?

 

 

GreggB
Pyrite | Level 9
please ignore. I meant to paste the log.
GreggB
Pyrite | Level 9

I just ran your code. a red scatterplot in  results viewer and black/white in the pdf file

 

536  ods pdf file="temp.pdf" color=full;
NOTE: Writing ODS PDF output to DISK destination "C:\Users\gbibb\temp.pdf", printer "PDF".
537  proc sgplot data=sashelp.class;
538  scatter x=height y=weight/markerattrs=(color=red);
539  run;

NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           0.37 seconds
      cpu time            0.18 seconds

NOTE: There were 19 observations read from the data set SASHELP.CLASS.

540  ods pdf close;
NOTE: ODS PDF printed 1 page to C:\Users\gbibb\temp.pdf.
Reeza
Super User
That path doesn't look valid to me....is there a note in the log that the file is created successfully or did you truncate it for the forum?
GreggB
Pyrite | Level 9
I don't have a good answer for that.
Reeza
Super User

@GreggB wrote:
I don't have a good answer for that.

I asked about VA instead of graphical programming in case you are trying to do this in Visual Analytics or something and that would then be outside of what I'm familiar with entirely and there could be default options affecting your output...if it's not and just SAS Studio via Code, this question probably belongs in the graphical forum.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 23 replies
  • 3425 views
  • 8 likes
  • 4 in conversation