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;
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;
@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.
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;
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?
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.
I don't think DATACONTRASTCOLORS works on VBAR plots. Try DATACOLORS=
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?
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.
@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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: