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

 

I have a table used by proc report to generate report in PDF format. There are several lines in that table and I want to make selected words in bold in a line. For example, I want "CY2017" and "123 hospital" in bold; how to do it? Thanks,

data inside;
	length line $100;
	line="CY2017 Feedback Report for 123 Hospital (January)  ~{newline 2} Since 2012...";
run;

options nodate nonumber center orientation=portrait papersize=letter;
ods escapechar = '~';
ods listing close;
ods pdf file="C:\Temp\test.pdf" notoc;  

ods layout start;
ods region x=1 in y=1.6 in height=6 in width=7 in;  

proc report data=inside nowd noheader 
   style(report)={rules=none frame=void cellspacing=0 cellpadding=.5pt};
	column line;
	define line /display  
	       style(column)= {background=white
	        foreground=black
	         font_weight=medium
			 just=left
			font_size=11pt
			font_face="Calibri"};
						
run;
ods layout end;   
ods _all_ close;
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  Yes, it worked for me with the Calibri font or Helvetica. It did NOT work with Arial Unicode MS in PDF. It did work with Arial in ODS HTML, but that's not what you wanted.  (BTW, I took out the font_weight=medium in your DEFINE statement too). Since I've stopped using Arial, I would just switch out the font. But if you must have Arial, then you'll need to open a track with Tech Support to see whether it is possible.

 

  Here are my results with 3 different fonts:

not_pdf_arial.png

  I reduced your code to non-macro calls:


%let bold1=%str(~{style[font_weight=bold]CY2017 Feedback Report} );
%let bold2=%str(~{style[font_weight=bold]Purpose});

		data inside;
		length line $500;
		line="&bold1 ~{newline 2}";
		output;
		line=catx(' ',"&bold2.: Testing different fonts and font_weight=bold.");
		output;
		run;

ods html;
ods escapechar='~';
ods pdf file="C:\Temp\output_test2.pdf" notoc startpage=no;  
 	proc report data=inside nowd noheader  
	     		style(report)={rules=none frame=void cellspacing=0 cellpadding=.5pt}
                style(lines)={font_face="Helvetica" just=c color=black font_weight=bold};
		column line;
		define line /display style(column)= {just=left font_size=11pt
							 font_face="Helvetica"};
	  compute before _page_;
	     line '1) FONT is Helvetica';
	  endcomp;
	run;

	 proc report data=inside nowd noheader  
	     		style(report)={rules=none frame=void cellspacing=0 cellpadding=.5pt}
                style(lines)={font_face="Arial Unicode MS" just=c color=black font_weight=bold};
		column line;
		define line /display style(column)= {just=left font_size=11pt
							 font_face="Arial Unicode MS"};
	  compute before _page_;
	     line '2) FONT is Arial Unicode MS';
	  endcomp;
	run;

	proc report data=inside nowd noheader  
	     		style(report)={rules=none frame=void cellspacing=0 cellpadding=.5pt}
                style(lines)={font_face="Calibri" just=c color=black font_weight=bold};
		column line;
		define line /display style(column)= {just=left font_size=11pt
							   font_face="Calibri"};
	  compute before _page_;
	     line '3) FONT is Calibri';
	  endcomp;
	run;
ods pdf close;

 

Cynthia

View solution in original post

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:

  You've declared an ESCAPECHAR for your NEWLINE function. All you have to do is use a STYLE function with ESCAPECHAR. When the text strings are going to be very long, I like to use Macro variables to make the code more readable. In this instance I created 2 macro variables &BOLD1 and &BOLD2 that are going to hold the entire string I want changed. In this case, I also specified different colors so the changes would stand out.

use_escapechar_and_macvar.png

 

 

Hope this helps,

Cynthia

nnl3256
Obsidian | Level 7

Thank you so much, Cynthia. It works after modifying my original posted code. By using the same syntax below, it does not work correctly on my side - none of bold1 and bold2 shows in bold. Does it work for you?

/*entire line in BOLD*/
%let bold1=%str(~{style[font_weight=bold]CY2017 Feedback Report} );
/*only word "Purpose" in BOLD*/ %let bold2=%str(~{style[font_weight=bold]Purpose}); %macro gen_rptdesc; data inside; length line $500; line="&bold1 ~{newline 2}"; output; line=catx(' ',"&bold2: Data provide organizations with important information that can be used ", "in a variety of ways. Collecting data on performance, outcomes, and other activities is the first step in helping the ", "organization improve its ability to provide quality care, treatment and services (P.01.01.01). The ", "hospital then compiles and analyzes the data (PI.02.01.01) and improves performance on an ongoing ", "basis (PI.03.01.01). ~{newline 2}"); output; run; %mend; %gen_rptdesc; %macro test_1stpg; options nodate nonumber center orientation=portrait papersize=letter; ods escapechar = '~'; ods listing close; ods pdf file="C:\Temp\test2.pdf" notoc; ods pdf startpage=now; ods layout start height=8.5 in width=7.9 in; ods region x=.4 in y=1.6 in height=6.6 in width=7.5 in; proc report data=inside nowd noheader style(report)={rules=none frame=void cellspacing=0 cellpadding=.5pt}; column line; define line /display style(column)= {background=white foreground=black font_weight=medium just=left font_size=11pt font_face="Arial Unicode MS"}; run; ods layout end; ods _all_ close; %mend; %test_1stpg;
Cynthia_sas
SAS Super FREQ

Hi:

  Yes, it worked for me with the Calibri font or Helvetica. It did NOT work with Arial Unicode MS in PDF. It did work with Arial in ODS HTML, but that's not what you wanted.  (BTW, I took out the font_weight=medium in your DEFINE statement too). Since I've stopped using Arial, I would just switch out the font. But if you must have Arial, then you'll need to open a track with Tech Support to see whether it is possible.

 

  Here are my results with 3 different fonts:

not_pdf_arial.png

  I reduced your code to non-macro calls:


%let bold1=%str(~{style[font_weight=bold]CY2017 Feedback Report} );
%let bold2=%str(~{style[font_weight=bold]Purpose});

		data inside;
		length line $500;
		line="&bold1 ~{newline 2}";
		output;
		line=catx(' ',"&bold2.: Testing different fonts and font_weight=bold.");
		output;
		run;

ods html;
ods escapechar='~';
ods pdf file="C:\Temp\output_test2.pdf" notoc startpage=no;  
 	proc report data=inside nowd noheader  
	     		style(report)={rules=none frame=void cellspacing=0 cellpadding=.5pt}
                style(lines)={font_face="Helvetica" just=c color=black font_weight=bold};
		column line;
		define line /display style(column)= {just=left font_size=11pt
							 font_face="Helvetica"};
	  compute before _page_;
	     line '1) FONT is Helvetica';
	  endcomp;
	run;

	 proc report data=inside nowd noheader  
	     		style(report)={rules=none frame=void cellspacing=0 cellpadding=.5pt}
                style(lines)={font_face="Arial Unicode MS" just=c color=black font_weight=bold};
		column line;
		define line /display style(column)= {just=left font_size=11pt
							 font_face="Arial Unicode MS"};
	  compute before _page_;
	     line '2) FONT is Arial Unicode MS';
	  endcomp;
	run;

	proc report data=inside nowd noheader  
	     		style(report)={rules=none frame=void cellspacing=0 cellpadding=.5pt}
                style(lines)={font_face="Calibri" just=c color=black font_weight=bold};
		column line;
		define line /display style(column)= {just=left font_size=11pt
							   font_face="Calibri"};
	  compute before _page_;
	     line '3) FONT is Calibri';
	  endcomp;
	run;
ods pdf close;

 

Cynthia

nnl3256
Obsidian | Level 7

Perfect! Font fortunately is not restricted. Thanks again!

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 4 replies
  • 3570 views
  • 0 likes
  • 2 in conversation