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

Hello,

I'm trying to use SAS Studio with ODS PDF and proc report to generate a report of a table, and currently I'm having issues with the style of the output but only for columns with a unicode check mark. All of my non-unicode columns are outputting correctly, but my check mark columns ("cmf_display" and "returned")  will not align to the center. Here is the section of code that should produce the output...

 

 

ods listing close;
ods noresults;
ods escapechar="~";
options nodate nonumber;
ods pdf file = "&cipath./RSchneider/Monthly Summary Automation Development/Output/&practice..pdf";
ods pdf text="~S={font=(Times,11pt,bold) textalign=center color=black}Practice Contact:";
ods pdf text="~S={font=(Times,11pt) textalign=center color=black}&contact.";
ods pdf text="~S={font=(Times,11pt) textalign=center color=black}&email.";

proc report data = out.final_report (where=(practice = "&practice."))
	style(hdr)=[foreground=&icpblue. font=("Times",11pt) background = white protectspecialchars=off fontweight=bold
	textalign=center verticalalign=center]
	style(column) = [cellpadding=1pt textalign=center];
	columns (color ("Date Sent" date_sent) ("Qtr" qtr) ("CMF" cmf_Display) ("Project" Practice_initiative)
		("Due Date" due_date) ("Returned" returned));

	/*Define the style elements for each column*/
	define color / noprint;
	define date_sent / display " " style = [cellwidth=1in background=white foreground=black protectspecialchars=off
		font=("Times",11pt) textalign=center verticalalign=middle];
	define qtr / display " " style = [cellwidth=1in background=white foreground=black protectspecialchars=off
		font=("Times",11pt,bold) textalign=center verticalalign=middle];
	define cmf_display / display " " style = [cellwidth=1in background=white foreground=black protectspecialchars=off
		font=("Times",11pt) textalign=center verticalalign=middle];
	define practice_initiative / display " " style = [cellwidth=1in background=white foreground=black protectspecialchars=off
		font=("Times",11pt) textalign=center verticalalign=middle];
	define due_date / display " " style = [cellwidth=1in background=white foreground=black protectspecialchars=off
		font=("Times",11pt) textalign=center verticalalign=middle];
	define returned / display " " style = [cellwidth=1in background=white foreground=black protectspecialchars=off
		font=("Times",11pt) textalign=center verticalalign=middle];

 

I have also attached an example of the output.


Output.PNG
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  Well, rather than muddy the issue with macro, and colors and the CALL DEFINE, I made some fake data and I simplified your code to get rid of the extraneous settings for foreground and background color.

--If you start with the PEARL style for PDF, the colors are black and white.

--I changed the style override string for ODS PDF TEXT= to be the newest (since 9.2 syntax).

--I used the full font name "Times New Roman" on my system, because I do not have a font called "Times", just "Times New Roman".

--When making the data, I used just the simple string ~{unicode 2714} (no quotes, no x) as shown where I make the data.

--Took out the foreground/background since they aren't needed with the PEARL style

-- changed HEADER color to purple just to show how overrides work

--used correct style(column)={...} on the DEFINE statements

 

Here is the output:

center_checkmark.png

 

and here's the program I used:


data final_report;
  length cmf_display returned $20;
  set sashelp.class(obs=3);
  cmf_display = '~{unicode 2714}';
  returned = cmf_display;
  date_sent = age;
  qtr = height;
  practice_initiative = weight;
  due_date = mdy(1,age,1984);
run;

ods escapechar="~";
options nodate nonumber;

** with PEARL style, default colors are black on white unless changed with an override;
ods pdf file = "c:\temp\testunicode_2714.pdf" startpage=no style=pearl;
ods pdf text= "~{style[font=('Times New Roman',11pt,bold) textalign=center] Practice Contact:}";
ods pdf text="~{style[font=('Times New Roman',11pt) textalign=center] somebody}";
ods pdf text="~{style[font=('Times New Roman',11pt) textalign=center]somebody@server.com}";

proc report data = final_report 
	style(hdr)=[foreground=purple font=("Times New Roman",11pt)  fontweight=bold
	            textalign=center verticalalign=center]
	style(column) = [cellpadding=1pt textalign=center];
	columns ( ("Date Sent" date_sent) ("Qtr" qtr) ("CMF" cmf_Display) ("Project" Practice_initiative)
		("Due Date" due_date) ("Returned" returned));

	/*Define the style elements for each column*/
	     
	define date_sent / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define qtr / display " " style(column) = [cellwidth=1in  
		font=("Times New Roman",11pt,bold) textalign=center verticalalign=middle];
	define cmf_display / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define practice_initiative / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define due_date / display " " style(column) = [cellwidth=1in 
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define returned / display " " style(column) = [cellwidth=1in  
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
  compute before _page_ / style={fontweight=bold};
     line '1) Similar to posted code using Unicode 2714';
	 line 'For PDF, checkmark cell is not using center align';
  endcomp;
run;


proc report data = final_report 
	style(hdr)=[foreground=purple font=("Times New Roman",11pt) fontweight=bold
	            textalign=center verticalalign=center]
	style(column) = [cellpadding=1pt textalign=center];
	columns ( ("Date Sent" date_sent) ("Qtr" qtr) ("CMF" cmf_Display) ("Project" Practice_initiative)
		("Due Date" due_date) ("Returned" returned));

	/*Define the style elements for each column*/
	      
	define date_sent / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define qtr / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt,bold) textalign=center verticalalign=middle];
	define cmf_display / display " " style(column) = [cellwidth=1in  leftmargin=.5in  
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define practice_initiative / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define due_date / display " " style(column) = [cellwidth=1in 
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define returned / display " " style(column) = [cellwidth=1in leftmargin=.5in  
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
  compute before _page_/ style={fontweight=bold};
     line '2) With LEFTMARGIN=.5in can move checkmark to middle of cell';
  endcomp;
run;
ods pdf close;

Hope this helps get you pointed to a solution.

 

cynthia

View solution in original post

8 REPLIES 8
Reeza
Super User

What version of SAS Studio and SAS are you using?

 

 

rschneider
Calcite | Level 5

Hi Reeza,

I'm using SAS Studio 3.3 (Enterprise Edition) and I believe the SAS version is 9.4.

Cynthia_sas
SAS Super FREQ
You did not show how you create the checkmark character. What UNICODE character did you use? Also, you do NOT show how the COLOR item was created or is being used.

Nor did you send any data that someone could use to run your program?

Not sure why you are using PROTECTSPECIALCHARS=OFF -- typically, you only use that for RTF and HTML when you are inserting control strings into the output. But PDF does not have control strings and you do not need PROTECTSPECIALCHARS for ODS ESCAPECHAR.

cynthia



cynthia
rschneider
Calcite | Level 5

Thank you for the quick response and apologies for not including all of the applicable information. As you can probably tell, this code is a work in progress and adapted from another piece of code that was used to output RTF files, which is why the PROTECTSPECIALCHARS option was used. I have now removed that option from the code.

 

The variables where the checkmark character needs to appear simply uses the string "~{unicode '2714'x}", where applicable. I have attached the dataset that my code references.

 

I know it is probably not as dynamic as it could be, but I used compute blocks to assign the background color. Please see my entire updated macro below.

 

%macro monthly;

 /*Create dataset for looping through practices and for obtaining contact info*/
 proc sort data = out.final_report; by practice descending date_sent; run;
 proc sort data = out.final_report nodupkey out=practices; by practice; run;
 
 /*create number variable to count the practices*/
 data praccount;
  retain rank;
  rank = _n_;
  set practices (keep=practice email contact);
 run;
 
 proc sql noprint;
  select count(practice) into :count
  from praccount;
 quit;
 
 %let i=1;
 %do %while (&i <= /*&count.*/10);
 
 data _null_;
  set praccount;
  where rank = &i.;
  call symput('practice',strip(practice));
  call symput('contact',strip(contact));
  call symput('email',strip(email));
 run;
 
ods listing close;
ods noresults;
ods escapechar="~";
options nodate nonumber;
ods pdf file = "&cipath./RSchneider/Monthly Summary Automation Development/Output/&practice..pdf";

 

 ods pdf text="~S={font=(Times,14pt,bold) textalign=center color=black}&Practice.";
 ods pdf text="~S={font=(Times,11pt,bold) textalign=center color=black}Practice Contact:";
 ods pdf text="~S={font=(Times,11pt) textalign=center color=black}&contact.";
 ods pdf text="~S={font=(Times,11pt) textalign=center color=black}&email.";
 ods pdf text="~S={font=(Times,11pt,bold) textalign=center color=black}Date Report Created: &sysdate9.";


 proc report data = out.final_report (where=(practice = "&practice."))
  style(hdr)=[foreground=&icpblue. font=("Times",11pt) background = white fontweight=bold
   textalign=center verticalalign=center]
  style(column) = [cellpadding=1pt textalign=center ];
   
  columns (color ("Date Sent" date_sent) ("Qtr" qtr) ("CMF" cmf_Display) ("Project" Practice_initiative)
    ("Due Date" due_date) ("Returned" returned));
   
  /*Define the style elements for each column*/
  define color / noprint;
  define date_sent / display " " style = [cellwidth=1in  foreground=black font=("Times",11pt) textalign=center verticalalign=middle];
  define qtr / display " " style = [cellwidth=1in foreground=black font=("Times",11pt,bold) textalign=center verticalalign=middle];
  define cmf_display / display " " style = [cellwidth=1in foreground=black font=("Times",11pt) textalign=center verticalalign=middle];
  define practice_initiative / display " " style = [cellwidth=1in foreground=black font=("Times",11pt) textalign=center verticalalign=middle];
  define due_date / display " " style = [cellwidth=1in foreground=black font=("Times",11pt) textalign=center verticalalign=middle];
  define returned / display " " style = [cellwidth=1in foreground=black font=("Times",11pt) textalign=center verticalalign=middle];

   compute date_sent;
    if color = "Green" then
     call define (_COL_, "style", "style=[background=&reportgreen]");
    if color = "Yellow" then
     call define (_COL_, "style", "style=[background=&reportyellow]");
    if color = "Red" then
     call define (_COL_, "style", "style=[background=&reportred]");

   endcomp;
    compute qtr; 
     if color = "Green" then
     call define (_COL_, "style", "style=[background=&reportgreen]");
    if color = "Yellow" then
     call define (_COL_, "style", "style=[background=&reportyellow]");
    if color = "Red" then
     call define (_COL_, "style", "style=[background=&reportred]");      

  endcomp; 
   compute cmf_display;
    if color = "Green" then
     call define (_COL_, "style", "style=[background=&reportgreen]");
    if color = "Yellow" then
     call define (_COL_, "style", "style=[background=&reportyellow]");
    if color = "Red" then
     call define (_COL_, "style", "style=[background=&reportred]");   

  endcomp;
   compute practice_initiative;
    if color = "Green" then
     call define (_COL_, "style", "style=[background=&reportgreen]");
    if color = "Yellow" then
     call define (_COL_, "style", "style=[background=&reportyellow]");
    if color = "Red" then
     call define (_COL_, "style", "style=[background=&reportred]"); 
   endcomp;
   compute due_date;
    if color = "Green" then
     call define (_COL_, "style", "style=[background=&reportgreen]");
    if color = "Yellow" then
     call define (_COL_, "style", "style=[background=&reportyellow]");
    if color = "Red" then
     call define (_COL_, "style", "style=[background=&reportred]");    

  endcomp;
   compute returned;
    if color = "Green" then
     call define (_COL_, "style", "style=[background=&reportgreen]");
    if color = "Yellow" then
     call define (_COL_, "style", "style=[background=&reportyellow]");
    if color = "Red" then
     call define (_COL_, "style", "style=[background=&reportred]");   endcomp;
 run;
 
 ods pdf close;


      %let i = %eval(&i+1);
      %end;
     
%mend;

%monthly

Cynthia_sas
SAS Super FREQ

Hi:

  Well, rather than muddy the issue with macro, and colors and the CALL DEFINE, I made some fake data and I simplified your code to get rid of the extraneous settings for foreground and background color.

--If you start with the PEARL style for PDF, the colors are black and white.

--I changed the style override string for ODS PDF TEXT= to be the newest (since 9.2 syntax).

--I used the full font name "Times New Roman" on my system, because I do not have a font called "Times", just "Times New Roman".

--When making the data, I used just the simple string ~{unicode 2714} (no quotes, no x) as shown where I make the data.

--Took out the foreground/background since they aren't needed with the PEARL style

-- changed HEADER color to purple just to show how overrides work

--used correct style(column)={...} on the DEFINE statements

 

Here is the output:

center_checkmark.png

 

and here's the program I used:


data final_report;
  length cmf_display returned $20;
  set sashelp.class(obs=3);
  cmf_display = '~{unicode 2714}';
  returned = cmf_display;
  date_sent = age;
  qtr = height;
  practice_initiative = weight;
  due_date = mdy(1,age,1984);
run;

ods escapechar="~";
options nodate nonumber;

** with PEARL style, default colors are black on white unless changed with an override;
ods pdf file = "c:\temp\testunicode_2714.pdf" startpage=no style=pearl;
ods pdf text= "~{style[font=('Times New Roman',11pt,bold) textalign=center] Practice Contact:}";
ods pdf text="~{style[font=('Times New Roman',11pt) textalign=center] somebody}";
ods pdf text="~{style[font=('Times New Roman',11pt) textalign=center]somebody@server.com}";

proc report data = final_report 
	style(hdr)=[foreground=purple font=("Times New Roman",11pt)  fontweight=bold
	            textalign=center verticalalign=center]
	style(column) = [cellpadding=1pt textalign=center];
	columns ( ("Date Sent" date_sent) ("Qtr" qtr) ("CMF" cmf_Display) ("Project" Practice_initiative)
		("Due Date" due_date) ("Returned" returned));

	/*Define the style elements for each column*/
	     
	define date_sent / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define qtr / display " " style(column) = [cellwidth=1in  
		font=("Times New Roman",11pt,bold) textalign=center verticalalign=middle];
	define cmf_display / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define practice_initiative / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define due_date / display " " style(column) = [cellwidth=1in 
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define returned / display " " style(column) = [cellwidth=1in  
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
  compute before _page_ / style={fontweight=bold};
     line '1) Similar to posted code using Unicode 2714';
	 line 'For PDF, checkmark cell is not using center align';
  endcomp;
run;


proc report data = final_report 
	style(hdr)=[foreground=purple font=("Times New Roman",11pt) fontweight=bold
	            textalign=center verticalalign=center]
	style(column) = [cellpadding=1pt textalign=center];
	columns ( ("Date Sent" date_sent) ("Qtr" qtr) ("CMF" cmf_Display) ("Project" Practice_initiative)
		("Due Date" due_date) ("Returned" returned));

	/*Define the style elements for each column*/
	      
	define date_sent / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define qtr / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt,bold) textalign=center verticalalign=middle];
	define cmf_display / display " " style(column) = [cellwidth=1in  leftmargin=.5in  
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define practice_initiative / display " " style(column) = [cellwidth=1in   
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define due_date / display " " style(column) = [cellwidth=1in 
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
	define returned / display " " style(column) = [cellwidth=1in leftmargin=.5in  
		font=("Times New Roman",11pt) textalign=center verticalalign=middle];
  compute before _page_/ style={fontweight=bold};
     line '2) With LEFTMARGIN=.5in can move checkmark to middle of cell';
  endcomp;
run;
ods pdf close;

Hope this helps get you pointed to a solution.

 

cynthia

rschneider
Calcite | Level 5

Adjusting the left margin of the column solved my problem. Thank you so much for your help Cynthia!!

strmwzrd
Fluorite | Level 6

I’m stumped with a problem printing Unicode characters to PDFs. They show up fine in my graphics and RTFs (results page) but not my PDFs. Any ideas (test code below)?  Thanks.

 

options nonumber nodate;


ods escapechar='^';
ods pdf file="c:/temp/unicode.pdf" STYLE=styles.dove;


title1 'Triangle is ^{unicode 26a0}';
title2 f= 'Arial Unicode MS' 'Triangle is ^{unicode 26a0}';

 

proc format ;
    value hgt
    69='^{unicode 26a0}' ; /* warning triangle */
run ;

 

proc report data=sashelp.class(obs=1);
    format height hgt. ;
run;


ods _all_ close;

strmwzrd
Fluorite | Level 6

Cynthia,

Tech support notified me this is a SAS issue with PDFs. They are working a solution.

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
  • 8 replies
  • 3369 views
  • 0 likes
  • 4 in conversation