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

Hi Team,

 

I am Using Title statement to create a report in SAS PDF.  We are in Plan to create 5000 reports dynamically. In every iteration title statement values will be captured from SAS Data set by using Macro. What happen is when i am using value from Data alligment of titles gets disturbed because of data value length. Could some one help for the same below is the sas code having title statement.

 

options pdfpageview=fitwidth;
/*options orientation=landscape nodate pageno=1 leftmargin=0.75in rightmargin=0.75in;*/
ods pdf file="/tmp/%sysfunc (compress(&ac)).pdf" style=sasweb startpage= never;
ods escapechar='~';
title1 j=L "~S={preimage='/tmp/image.JPG'}";
Title2 color=brown height=5 justify=left font="arial" "&cname";
Title3 color=brown justify=left BOLD height=3.5 font="arial"
"~{newline 1} ACCOUNT DETAILS ~{nbspace 53}TRANSACTION PERIOD: &date1 to &date2";
title4 j=l "~S={preimage='/tmp/image.jpg'}";
Title5 color=brown j=left height=2.5 font="arial"
"~{style [fontweight=bold]Branch Office: ABC Corporation} ~{nbspace 30}~{style [fontweight=bold] Customer Address}:
~{newline 2} %sysfunc (strip(&address1)) ~{nbspace 60} &add1
~{newline 1} %sysfunc (strip(&addresss2)) - &brpin
~{nbspace 48} &add2

 

in Above code the value of &address1 and &address2 is varing hence &add1 and &add2 values not justified.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

You imply that you have values in a data set and build macro variables from those but do not give any example. So this is an example of creating a couple of strings to align text. Sort of. If you are using any output that uses proportional fonts then you need something else related to the output destination tab alignments or such.

 

data example;
   address1= "1234 Somestreet, SomeCity, Postcode";
   address2= '1 A St., Town, AK';
   add1 = 'added text';
   add2 = 'some other text to add';
   /* assume that I want the ADD variable to 
   start in column 60 the space variable needs to be
   long enough to hold all the spaces to the desired 
   column position in case the address variable is 
   missing*/
   length longstr1 longstr2 $ 150 space1 space2 $ 60;;
   /* the character below is a NULL character, ASCII 255*/
   space1 = repeat(' ',60-length(address1));
   space2 = repeat(' ',60-length(address2));
   longstr1= cats(address1,space1,add1);
   longstr2= cats(address2,space2,add2);
   put longstr1;
   put longstr2;
   /* create macro variables if you must from
   longstr1 and longstr2*/
run;


Note that the code windows use a fixed width font so this aligns nicely:

WWWWWWWWWWWWWWWWWWWW
iiiiiiiiiiiiiiiiiiii

But pasting the exact same strings into the message window on the forum, which uses a Proportional Font we get:

WWWWWWWWWWWWWWWWWWWW

iiiiiiiiiiiiiiiiiiii

 

Since W is wider than lower case I then alignment based on numbers of characters is problematic. The text approach I showed may be closer but unless you use a monospace font like Courier or SAS Monospace in the ODS style of your titles be prepared to be disappointed. Until you figure out how to set tab stops or similar in PDF. I don't know how and currently have no interest in investigating how or even if possible.

 

View solution in original post

2 REPLIES 2
ballardw
Super User

You imply that you have values in a data set and build macro variables from those but do not give any example. So this is an example of creating a couple of strings to align text. Sort of. If you are using any output that uses proportional fonts then you need something else related to the output destination tab alignments or such.

 

data example;
   address1= "1234 Somestreet, SomeCity, Postcode";
   address2= '1 A St., Town, AK';
   add1 = 'added text';
   add2 = 'some other text to add';
   /* assume that I want the ADD variable to 
   start in column 60 the space variable needs to be
   long enough to hold all the spaces to the desired 
   column position in case the address variable is 
   missing*/
   length longstr1 longstr2 $ 150 space1 space2 $ 60;;
   /* the character below is a NULL character, ASCII 255*/
   space1 = repeat(' ',60-length(address1));
   space2 = repeat(' ',60-length(address2));
   longstr1= cats(address1,space1,add1);
   longstr2= cats(address2,space2,add2);
   put longstr1;
   put longstr2;
   /* create macro variables if you must from
   longstr1 and longstr2*/
run;


Note that the code windows use a fixed width font so this aligns nicely:

WWWWWWWWWWWWWWWWWWWW
iiiiiiiiiiiiiiiiiiii

But pasting the exact same strings into the message window on the forum, which uses a Proportional Font we get:

WWWWWWWWWWWWWWWWWWWW

iiiiiiiiiiiiiiiiiiii

 

Since W is wider than lower case I then alignment based on numbers of characters is problematic. The text approach I showed may be closer but unless you use a monospace font like Courier or SAS Monospace in the ODS style of your titles be prepared to be disappointed. Until you figure out how to set tab stops or similar in PDF. I don't know how and currently have no interest in investigating how or even if possible.

 

ShammiKalsi
Fluorite | Level 6

Hi Ballardw,

 

Thanks for your response!! 

 

i have used monospace font family and allignment of address1 and address2.

 

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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