BookmarkSubscribeRSS Feed
SanjayM
Calcite | Level 5
Hi

I have a title as

REPRORT_ID Report for Invoices Page 1

I want Report_ID to be left aligned
Report title i.e. Report for Invoices as center aligned
Page 1 i.e. page numberings as right aligned
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
Hi:
It depends on your destination. If you are using the LISTING destination and sending output to an ASCII text file, then you cannot variably adjust the alignment of text strings for Text output, -easily-. There used to be a SAS macro program that you could run that would figure out your LINESIZE and then split the string, but you'd have to ask Tech Support whether they even know how to get a copy of that macro -- I used to use something like it in my mainframe days (long, long ago).

However, generally, for HTML, RTF and PDF, you can do this:[pre]
title j=l 'Left' j=c 'Center' j=r 'Right';[/pre]

Not all HTML-based tagsets will "accept" this syntax, however. If you use MSOFFICE2K tagset, the differing strings will appear on 3 separate lines.

Here's some code to test:
[pre]
options nodate nonumber;

ods listing;
ods html file='c:\temp\test_title.html' style=sasweb;
ods rtf file='c:\temp\test_title.rtf';
ods pdf file='c:\temp\test_title.pdf';
ods msoffice2k file='c:\temp\test_title_mso.html' style=sasweb;

ods escapechar = '~';
title j=r 'Page ~{thispage}';
title2 j=l 'Left' j=c 'Center' j=r 'Right';

proc print data=sashelp.class;
var name age height;
run;
ods _all_ close;
[/pre]

cynthia
SanjayM
Calcite | Level 5
Thanks, I think it should work for PROCREPORT as well.
deleted_user
Not applicable


> It depends on your destination. If you are using
> the LISTING destination and sending output to an
> ASCII text file, then you cannot variably adjust the
> alignment of text strings for Text output, -easily-.
> There used to be a SAS macro program that you could
> run that would figure out your LINESIZE and then
> split the string, but you'd have to ask Tech Support
> whether they even know how to get a copy of that
> macro -- I used to use something like it in my
> mainframe days (long, long ago).



I still occasionally use output destinations that support this Cynthia, although I haven't written a macro to perform the task.

The key constraint is that the output medium must be using a non-proportional font, otherwise all bets are off and this won't work consistently as expected. Aside from anything else, a space character in a proportional font is narrower than "i" in either case, or "L" in lower case.

Our old friend %SysFunc( GetOption( LineSize) ) will retrieve the system setting for the length of the output line in characters, and use of the Left(), Trim() and Length() functions will retrieve the length of the title string which can then be prepended with the appropriate number of spaces.

I would never do this in ODS. As you showed there are many approaches which are much less complex and easier to achieve, however, for producing survey forms I still tend to program with the approach that I know I can make work quickly.

Kind regards

David

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2782 views
  • 0 likes
  • 3 in conversation