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

If I submit the following code, except for the first and last lines that contains ODS, I get a nice output in my  html window with color. However, if I include the ODS statements at the beginning and end, I get output that has no color. I appreciate any help.

 

ods pdf file='G:\Departments\Research\MAP\1617\Fall 2016\Freqs of Pct Correct by Course Grade.pdf';
*math*;
proc sort data=mmap;
by letter;
proc freq data=mmap noprint;
by letter;
tables cat / out=FreqOutMath;
run;
title "Percent Correct on Math MAP by Course Letter Grade";
proc sgplot data=FreqOutMath;
vbar letter / response=Percent group=cat groupdisplay=stack;
xaxis discreteorder=data;
yaxis grid values=(0 to 100 by 10) label="Percentage of Total with Group";
run;
ods pdf close;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

I'd probably start with the colourprinting option.

 

options nodate number pageno=1 orientation=landscape colorprinting=yes papersize=letter missing='N' nobyline
bottommargin=0in topmargin=0in leftmargin=0in rightmargin=0in;

 

 

View solution in original post

17 REPLIES 17
ballardw
Super User

You might try specifying a STYLE= option on the ODS PDF statement, likely best would be to match the style used by HTML.

I believe the default PDF style doesn't include color. The log may have shown a bunch of lines about elements not defined, those would be mostly the colors used by graphics.

GreggB
Pyrite | Level 9

I don't know what style the HTML used.

ballardw
Super User

If you are using Base SAS go to the menu Tools>Options>Preferences>Results

There should be a Style indicated under HTML. Possibly Default or HTMLBlue.

Since the SAS supplied styles vary from release to release I can't be sure which one you want, or if someone in your organization may have created and specified something else for your default style.

 

PDF and RTF ods destinations have their own defaults that you need to override though to get color.

GreggB
Pyrite | Level 9

The style says HTMLBlue.  I'm not sure what to do with info to get my ods pdf file = ... statement to export in color.

Reeza
Super User

Add STYLE as indicated earlier. 

 

 

 

ODS PDF file='.....' style=HTMLBlue ...;

 

rest of code;

 

ods pdf close;

GreggB
Pyrite | Level 9

Still no change. The Results Viewer shows color but the exported pdf file is gray.

 

ods pdf file='G:\Departments\Research\MAP\1617\Fall 2016\Freqs of Pct Correct by Course Grade.pdf' style=htmlblue;
*math*;
proc sort data=mmap;
by letter;
proc freq data=mmap noprint;
by letter;
tables cat / out=FreqOutMath;
run;
title "Percent Correct on Math MAP by Course Letter Grade";
proc sgplot data=FreqOutMath;
vbar letter / response=Percent group=cat groupdisplay=stack;
xaxis discreteorder=data;
yaxis grid values=(0 to 100 by 10) label="Percentage of Total with Group";
run;
ods pdf close;

ballardw
Super User

It may be time to see the log with the entire ODS PDF "sandwich" code.. Possibly the original result file isn't being replaced for some reason such as the PDF is open by another program.

GreggB
Pyrite | Level 9

Here's the log. The pdf file is being created and sent to the appropriate destination.

 

150 ods pdf file='G:\Departments\Research\MAP\1617\Fall 2016\Freqs of Pct
150! Correct by Course Grade.pdf' style=htmlblue;
NOTE: Writing ODS PDF output to DISK destination
"G:\Departments\Research\MAP\1617\Fall 2016\Freqs of Pct Correct by
Course Grade.pdf", printer "PDF".
151 *math*;
152 proc sort data=mmap;
153 by letter;

NOTE: There were 4640 observations read from the data set WORK.MMAP.
NOTE: The data set WORK.MMAP has 4640 observations and 14 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.09 seconds
cpu time 0.00 seconds


154 proc freq data=mmap noprint;
155 by letter;
156 tables cat / out=FreqOutMath;
157 run;

NOTE: There were 4640 observations read from the data set WORK.MMAP.
NOTE: The data set WORK.FREQOUTMATH has 27 observations and 4 variables.
NOTE: PROCEDURE FREQ used (Total process time):
real time 0.12 seconds
cpu time 0.01 seconds


158 title "Percent Correct on Math MAP by Course Letter Grade";
159 proc sgplot data=FreqOutMath;
160 vbar letter / response=Percent group=cat groupdisplay=stack;
161 xaxis discreteorder=data;
162 yaxis grid values=(0 to 100 by 10) label="Percentage of Total with
162! Group";
163 run;

NOTE: Writing HTML Body file: sashtml.htm
NOTE: PROCEDURE SGPLOT used (Total process time):
real time 6.35 seconds
cpu time 0.32 seconds

NOTE: There were 27 observations read from the data set WORK.FREQOUTMATH.

164 ods pdf close;
NOTE: ODS PDF printed 1 page to G:\Departments\Research\MAP\1617\Fall
2016\Freqs of Pct Correct by Course Grade.pdf.

 

Reeza
Super User

Can you run the code I posted and attach the resulting PDF file. 

GreggB
Pyrite | Level 9

1 ods pdf file='sample.pdf' style=htmlblue;
NOTE: Writing ODS PDF output to DISK destination
"C:\Users\gbibb\sample.pdf", printer "PDF".
NOTE: This SAS session is using a registry in WORK. All changes will be
lost at the end of this session.
2
3 title 'Style demo';
4 proc print data=sashelp.class;
NOTE: Writing HTML Body file: sashtml.htm
5 run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.85 seconds
cpu time 0.34 seconds


6
7 ods pdf close;
NOTE: ODS PDF printed 1 page to C:\Users\gbibb\sample.pdf.

ballardw
Super User

The note about registry in Work makes me wonder if you have something odd with your ODS path for finding styles.

What do you get when you run:

proc template;
   path show;
run;

 

 

Or possibly something is confusing the color definitions for your system.

GreggB
Pyrite | Level 9

73 proc template;
74 path show;
Current ODS PATH list is:

1. SASUSER.TEMPLAT(UPDATE)
2. SASHELP.TMPLMST(READ)
75 run;
NOTE: PROCEDURE TEMPLATE used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

 

Reeza
Super User

Try another style - Seaside or Meadow. 

 

And do you know what this NOTE  means:

 

 

1 ods pdf file='sample.pdf' style=htmlblue;
NOTE: Writing ODS PDF output to DISK destination
"C:\Users\gbibb\sample.pdf", printer "PDF".

GreggB
Pyrite | Level 9

No luck. I went back to a program I ran last week and ran it again. It outputs with colors as expected.  Here's the code I used to define the pdf file. A colleague shared this code with me so I'm not familar with all of the options here. I'm wondering what option(s) I should apply to my current code that's not working.

 

 

***** DEFINE PDF FILE. *****;
options nodate number pageno=1 orientation=landscape colorprinting=yes papersize=letter missing='N' nobyline
bottommargin=0in topmargin=0in leftmargin=0in rightmargin=0in;
ods pdf file="G:\Departments\Research\SpecialServices\Profile Reports\&yr.\Profile Reports 2015-2016 By School.pdf";

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
  • 17 replies
  • 4318 views
  • 0 likes
  • 3 in conversation