BookmarkSubscribeRSS Feed
Olivier
Pyrite | Level 9
Hi all.

I'm currently looking for a style attribute similar to JUST= which would justify paragraphs on both left and right ; it seems that I only can left-justify (ending up in irregular line lengths on the right, just as this post) or right-justify (similar problem on the left).
If not provided in SAS, maybe some PDF inline formatting option is available (this is for providing PDF reports including text) ?

Thanks in advance for any suggestion, trick, or satanic rite to achieve my goal.
Olivier
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi, Olivier:
I don't know the PDF way to do full justify. There must be one, but I only know of an RTF and HTML way.

The RTF way involves the RTF control string '\qj' and the HTML way involves either the align="justify" attribute or the "text-align: justify" CSS property value. These 2 methods do not really involve ODS style attributes -- they are the "vanilla" methods specified by each markup language. However, the methods DO need an ODS style attribute to work -- I have to tell ODS that I know what I'm doing in using the special characters (like \ or { for RTF) or the < and > for HTML. So I have to set PROTECTSPECIALCHARS=OFF.

Here's some code to test. Just a few notes. If your browser does not use align=justify, then you'll have to try the text-align: justify which belongs to CSS. Also, I prefer not to break long text strings over a line when I'm assigning a long character variable. So I'm assigning my long text via macro variables. If you already have a variable with "big text" to justify, then you'll only need to add the RTF control strings or HTML tags to your variable value.

For more information about the RTF spec:
http://kobesearch.cpan.org/htdocs/RTF-Writer/Cookbook.html

For more info about HTML and CSS and justifying text blocks:
http://www.westciv.com/style_master/academy/css_tutorial/index.html (or any basic HTML/CSS reference book)

cynthia
[pre]
options nodate nonumber center;

%let rt0 = %nrstr(\li180\ri1440\fi480\qj);
%let t1 = %nrstr(Twas brillig and the slithy toves did gyre and gimble in the wabe. );
%let t2 = %nrstr(All Mimsy were the borogroves and the momeraths outgrabe. );
%let t3 = %nrstr(Beware the Jabberwock my son, the jaws that bite the claws that snatch. );
%let t4 = %nrstr(Beware the Jubjub bird and shun the frumious Bandersnatch. );
%let t5 = %nrstr(He took his vorpal sword in hand: Long time the manxome foe he sought -- );
%let t6 = %nrstr(So rested he by the Tumtum tree, And stood awhile in thought. );
%let t7 = %nrstr(And, as in uffish thought he stood, The Jabberwock, with eyes of flame, );
%let t8 = %nrstr(Came whiffling through the tulgey wood, And burbled as it came! );

data jabber;
length var $1000;
bigrtf = "{\pard &rt0 &t1.&t2.&t3.&t4.&t5.&t6.&t7.&t8 \par}";
bightml = "<div align='justify'>&t1.&t2.&t3.&t4.&t5.&t6.&t7.&t8</div>";
run;

ods rtf file='c:\temp\jabber.rtf';
proc print data=jabber ;
var bigrtf / style(data)={protectspecialchars=off};
run;
ods rtf close;

ods html file='c:\temp\jabber.html';
proc print data=jabber;
var bightml / style(data)={protectspecialchars=off};
run;
ods html close;

ods html file='c:\temp\jabber2.html';
proc print data=jabber;
var bightml / style(data)={protectspecialchars=off htmlstyle="text-align: justify;"};
run;
ods html close;
[/pre]
Olivier
Pyrite | Level 9
Hi Cynthia.

Thanks for the tips ; unfortunately, this is really PDF that I need to produce using SAS.
So I will hope that someone reading this would know the PDF instruction for full justification, similar to the \qj instruction in RTF. I don't succeed in finding a document describing PDF as the RTF cookbook you're mentionning.

Anyway, thanks a lot for taking time on my problem.
Olivier
Cynthia_sas
SAS Super FREQ
Hi:
Your best bet for PDF help is Tech Support. If they don't know the answer, they can ask the PDF/ODS developers.

cynthia

ps...PDF was once explained to me as a very "low level" text formatting language. It is supposed to replicate the process of sending your document to a printer, only instead of a physical printer, the document was going to a file. Supposedly commands in PDF are akin to "move x fractions of a dimension to the right from the left margin. move y fractions of a dimension down from the top margin. draw the letter H in the font of Helvetica at 10 pt size. draw the letter E in the font of Helvetica at 10 pt size. draw the letter L in the font of Helvetica at 10 pt size. draw the letter L in the font of Helvetica at 10 pt size. draw the letter O in the font of Helvetica at 10 pt size." etc, etc. That's how it was explained to me as the reason why I couldn't find any "markup" tutorials similar to HTML or RTF language tutorials.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 1167 views
  • 0 likes
  • 2 in conversation