Table 15.4 Example CMYK Colors
Hexadecimal
Representation Color
cmykFF000000 cyan
k00FF0000 magenta
cmyk0000FF00 yellow
kFFFF0000 blue
cmykFF00FF00 green
k00FFFF00 red
cmykFFFFFF00 process black, using cyan, magenta, and yellow
k000000FF black
The first byte of the hexadecimal number represents cyan. The second byte represents
magenta. The third byte represents yellow. The fourth byte represents black.
This example uses the STYLE option to set the column background color to magenta
and sets the foreground color to white. The TITLE statement sets the output title to blue.
options obs=5 nodate;
ods html close;
ods pdf;
proc print data=sashelp.demographics label
style(header)={background=cmyk00ff0000 foreground=k00000000} noobs;
var name pop;
label name=Country Name pop=Population;
title color=kffff0000 'Demographics 2005';
run;
ods pdf close;
ods html;
Universal Printing 249
Figure 15.3 CMYK Color Specified in the STYLE Option
Note: When you use the TIFFk Universal Printer, specify the UPRINTCOMPRESSION
system option to avoid very large TIFF files.
RGB and RGBA Colors
RGB and RGBA colors combines red, green, and blue colors in different ratios to create
colors. The A is the alpha channel, which represents a percentage of opacity.
You specify RGB colors as a triple of hexadecimal numbers, ranging from 00–FF, Each
hexadecimal number indicates how much of the red, green, or blue is included in the
color. RGBA color includes an additional hexadecimal number for the alpha channel that
indicates how transparent the color is. FF is opaque and 00 is transparent. In both RGB
and RGBA color specifications, the first hexadecimal number is red, the second, is
green, and the third is blue. In RGBA colors, the fourth hexadecimal number is the alpha
channel specification.
You can specify RGB and RGBA colors where ever colors can be set (for example, as an
option in the VBAR statement in the SGPLOT procedure or in the TITLE statement).
For RGB colors, preface the hexadecimal number with a CX. For RGBA colors, preface
the hexadecimal number with RGBA or A.
The following SGPLOT procedure uses an RGBA color to create the bar labels:
ods html close;
ods printer printer=png;
proc sgplot data=sashelp.stocks (where=(date >= "01jan2000"d
and date <= "01jan2001"d
and stock = "IBM"));
title color=a6495edff "Stock Volume vs. Close";
vbar date / response=volume
datalabel
datalabelattrs=(color=a8a44ff8a size=10);
vline date / response=close y2axis;
run;
250 Chapter 15 Printing with SAS
title;
ods printer close;
ods html;
Here is the PNG file with bar labels:
Figure 15.4 RGBA Color Specified for the Bar Labels
Example: Static and Varying Background Color in a Table Using
RGBA Colors
This example program does the following:
Creates the format PCT. using a DATA _NULL_ statement. The DATA step defines
salary ranges of $3,000.00 and calculates an RGBA color value for each salary
range. The CALL EXECUTE statement is used to output the FORMAT procedure
code as it is generated.
Creates a data set.
The PRINT procedure uses an RGBA color value for the background of the table
header and formats the salary variable using the PCT. format.
options nodate;
/* Create the PCT format. */
/* The color variable is a concatenation of calculated */
Universal Printing 251
/* hexadecimal values. */
data _null_ ;
call execute('proc format fmtlib ; value pct');
max=10000;
maxloop=255;
do i=1 to maxloop by 10;
color='RGBA'||put(((maxloop)/(maxloop+i)*200),hex2.)
||put(((maxloop)/(maxloop+i)*235),hex2.)
||put(((maxloop)/(maxloop+i)*255),hex2.)||'95';
from=max;
to=(max+3000);
max=max+3000;
/* Create salary ranges of $3000.00 equal to the calculated RGBA color value.*/
call execute(put(from,best.)||'-'||put(to,best.)||'='||quote(color));
end;
/* Create RGBA values for missing values and values outside the salary ranges. */
call execute('.="RGBAF7F5F0480" other="RGBAFF2A2A88"; run;');
run;
data staff;
infile datalines dlm='#';
input Name $16. IdNumber $ Salary
Site $ HireDate date7.;
format hiredate date7.;
datalines;
Capalleti, Jimmy# 2355# 21163# BR1# 30JAN09
Chen, Len# 5889# 20976# BR1# 18JUN06
Davis, Brad# 3878# 19571# BR2# 20MAR84
Leung, Brenda# 4409# 34321# BR2# 18SEP94
Martinez, Maria# 3985# 49056# US2# 10JAN93
Orfali, Philip# 0740# 50092# US2# 16FEB03
Patel, Mary# 2398# 35182# BR3# 02FEB90
Smith, Robert# 5162# 40100# BR5# 15APR66
Sorrell, Joseph# 4421# 38760# US1# 19JUN11
Zook, Carla# 7385# 22988# BR3# 18DEC10
;
run;
ods html close;
ods pdf file='outpdf.pdf';
proc print data=staff noobs label
style(HEADER)={background=rgbac7eafe95 fontstyle=italic}
style(DATA)={foreground=black};
var name IdNumber ;
var salary /style(DATA)={background=pct.};
label IdNumber='Employee Number' salary='Salary in U.S. Dollars';
format salary dollar7.;
title 'Generated Colors for the Variable Salary';
run;
ods pdf close;
Log 15.1 Static and Varying Background Color in a Table Using RGBA Colors
252 Chapter 15 Printing with SAS
501 options nodate;
502
503 /* Create the PCT format. */
504 /* The color variable is a concatenation of calculated */
505 /* hexadecimal values. */
506
507 data _null_ ;
508 call execute('proc format fmtlib ; value pct');
509 max=10000;
510 maxloop=255;
511 do i=1 to maxloop by 10;
512 color='RGBA'||put(((maxloop)/(maxloop+i)*200),hex2.)||put(((maxloop)/
(maxloop+i)*235),
512! hex2.)
513 ||put(((maxloop)/(maxloop+i)*255),hex2.)||'95';
514 from=max;
515 to=(max+3000);
516 max=max+3000;
517
518 /* Create salary ranges of $3000.00 equal to the calculated RGBA
color value.*/
519 call execute(put(from,best.)||'-'||put(to,best.)||'='||quote(color));
520 end;
521
522 /* Create RGBA values for missing values and values outside the salary
ranges. */
523 call execute('.="RGBAF7F5F0480" other="RGBAFF2A2A88"; run;');
524 run;
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
Universal Printing 253
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.150.231