/* Richard A. DeVenezia * April 17, 2004 * * Some macros to simplfy the task of placing bulleted narrative * in a pdf document. * * Originally posted to SAS-L on April 17, 2004 */ %macro bullets_start ; data bullets; attrib text length=$500 bullet_code length=8 bullet_font length=$40 bullet_size length=$10 ; retain _char_ ''; retain _numeric_ .; stop; run; %mend; %macro bullet_add (text, bullet_code=., font_face=, font_size=); %* font_size must include units, e.g. 10pt, 1cm; %local face size; %let text = %qsysfunc(tranwrd(&text,%str(%"),%str(%"%"))); %let face = %qsysfunc(tranwrd(&font_face,%str(%"),%str(%"%"))); %let size = %qsysfunc(tranwrd(&font_size,%str(%"),%str(%"%"))); proc sql; insert into bullets values ( "&text" , &bullet_code , "&face" , "&size" ); quit; %mend; %macro bullets_end ( default_bullet_code = 43 , default_bullet_font = Dingbats , default_bullet_size = , escape_char = '^' ); %local face size; %let face = %qsysfunc(tranwrd(&default_bullet_font,%str(%"),%str(%"%"))); %let size = %qsysfunc(tranwrd(&default_bullet_size,%str(%"),%str(%"%"))); * ods pdf startpage = never; ods escapechar = &escape_char; proc report nowindows data=bullets style(report)={borderwidth=0} noheader ; columns bullet_code bullet_font bullet_size text; define bullet_code / display noprint; define bullet_font / display noprint; define bullet_size / display noprint; compute text; length set_style $200; length clear_style $10; length font_face $40; length font_size $10; if bullet_code = . then bullet = byte (&default_bullet_code); else bullet = byte (bullet_code); if bullet_font eq '' then font_face = "&face"; else font_face = bullet_font; if bullet_size eq '' then font_size = "&size"; else font_size = bullet_size; if font_face ne '' or font_size ne '' then do; set_style = &escape_char || 'S={'; if font_face ne '' then set_style = trim(set_style) || ' font_face=' || font_face; if font_size ne '' then set_style = trim(set_style) || ' font_size=' || font_size; set_style = trim(set_style) || '}'; clear_style = &escape_char || 'S={} ' || &escape_char || 'm'; end; else do; set_style = ''; clear_style = ' ' || &escape_char || 'm'; end; text = trim(set_style) || bullet || trim(clear_style) || text; endcomp; run; * ods pdf startpage = now; %mend; *--- generate a report in pdf format ---; ods listing close; ods pdf notoc file="%sysfunc(pathname(WORK))/report.pdf" startpage=never; options nocenter nonumber nodate; title; footnote; proc print data=sashelp.class; run; options mprint mtrace ; %bullets_start %bullet_add(This is bullet #1) %bullet_add(This is bullet #2) %bullet_add(This is bullet #3) %bullet_add(Bullet #4 is code 96, bullet_code=96) %bullet_add(This is bullet #5) %bullet_add(This is bullet #6) %bullet_add(%nrstr(This is bullet #7, it has a comma)) %bullet_add(%str(This is bullet #8, it has a single quote. It do don%'t it?)) %bullet_add(%nrstr(Bullet #9 has ampersands and percent signs &ersand, %percent)) %bullet_add(This is a bullet in Helvetica 32pt, font_face = Helvetica, font_size=32pt) %bullet_add(This is a bullet) %bullet_add(Is this a bullet? "Yes, it is") %bullets_end ods pdf close;