I'm producing multi-page detailed reports with long text strings as well as graphs and tables. The text strings are used for titles on pages, as well as tables and graphs. Long text strings are also used for detailed explanations of the report contents. I'm using ODS LAYOUT with multiple regions to control each page. The document is written to a PDF. To maximize control over the text strings, I'm using ODS TEXT="....." with ods escapechar inline formatting for fine formatting needs such as bolding specific pieces of text.
Here's the text I'm using:
ods text="~{style[font_size=3.25 just=c]Antibiotic Stewardship Across 3 Common Childhood Conditions}";
ods text="~{style[font_size=3.25 just=c]Provider-Specific Data for ~{style[just=c fontweight=bold fontstyle=italic] &prov_full_no_quote.}} ";
ods text="~{style[font_size=3.25 just=c]Ambulatory Care 1/2014 - 6/2020}";
All of these text lines should be centered. The second line of text comes out left justified while the first and third line are centered. (see sample output below.)
This is one example. I am seeing this behavior intermittently throughout the document. I've tried changing the sequence of the inline formatting commands.
Anyone have suggestions for me?
Is there any chance that your macro variable has some non-printing characters past the desired text? That might make the centering calculation think that the string to center is much longer than appears visible.
You might try dropping the second Just = in the style as well.
I now see a pattern in when the just=c inline formatting doesn't occur. It's whenever the line of text includes a macro var. The macro does successfully resolve, but could this this a timing issue of resolution of the macro preventing the proper formatting?
Is there any chance that your macro variable has some non-printing characters past the desired text? That might make the centering calculation think that the string to center is much longer than appears visible.
You might try dropping the second Just = in the style as well.
Ah yes. Thanks for your suggestion. Although I knew the length of the var going into the macro, it was GROWING behind the scenes. I added %sysfunc(strip(¯o_var)) and the output is now properly centered.
@kareng wrote:
Ah yes. Thanks for your suggestion. Although I knew the length of the var going into the macro, it was GROWING behind the scenes. I added %sysfunc(strip(¯o_var)) and the output is now properly centered.
It is probably easier to just not put the trailing spaces into the macro variable to begin with.
Use CALL SYMPUTX() instead of the older CALL SYMPUT(). Use the TRIMMED keyword in PROC SQL.
data _null_;
set myds;
call symputx('mymvar',mydsvar);
run;
proc sql noprint;
select mydsvar into :mymvar trimmed from myds;
quit;
I thought I had handled the training spaces by using this code to populate the macro in PROC SQL:
compbl(trimn(left(complete_title))) into: &prov_full_no_quote.
I was not previously aware of the PROC SQL keyword TRIMMED. Thanks!
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!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.