Hi,
I am having some issues with trying to indent text in an RTF output. Code and input data are available below. If you look at the attached images, the lines starting with a number (ord2 in(5 6 7 8 13) are not displayed correctly.
Does anybody have any idea why this may be? All the other rows are displayed as expected. I do not ever remember coming across this before when I have used identation like in the code below.
data have;
retain ord1 ord2 ord3 col1 col2 _page _pagev ;
infile datalines delimiter="¬" truncover;
LENGTH col1 $200. col2 _pagev $20.;
input ord1 ord2 ord3 col1 $ col2 $ _page _pagev $;
datalines;
1¬1¬0¬Xxxxxx xx xxxxxxxx xxx xxxx xxx xxxxxxxxxx [x]¬000 (000.0)¬1¬
1¬2¬1¬Xxxxxx xxxxxxxxx/xxxxxxxxx xxxxxxxx¬000 ( 00.0)¬1¬
1¬3¬1¬Xxxxxxx¬0 ( 0.0)¬1¬
2¬4¬0¬Xxxxxx xx xxxxxxxxx/xxxxxxxxx xxxxxxxx xxxxxx¬ ¬1¬
2¬5¬1¬1¬000 ( 00.0)¬1¬
2¬6¬1¬2¬00 ( 00.0)¬1¬
2¬7¬1¬3¬00 ( 0.0)¬1¬
2¬8¬1¬4¬0 ( 0.0)¬1¬Page 1 of 3
3¬9¬0¬Xxxxxxxxx xxxxxxxx xxxxxx [x]¬000 ( 00.0)¬2¬
3¬10¬1¬Xxxxxxx xx xxxxxx x xxxxxx xxxxxxxx xxxxxxx, xxxxx xxxxxxxx xxxxxxxxxx xxxx xxx xxxxxxxxxxxx xxx xxxxxxxxxxxx xxxxxx xx xxx xxxxxxxx xxxxxxx xxxx (XXX) xxx xx xxx xxxxxxxx.¬00 ( 0.0)¬2¬
3¬11¬1¬Xxxxxxxxx xx xxxxxx xxx xxxxx, xxxxxxx XXX xxxxx xx xxx xxxxxxxxx xxxxx-xxxxxxxx xxxxxxxxxx, xxxxxxxx, xxx xxxxxxxx.¬0 ( 0.0)¬2¬
3¬12¬1¬Xxxxxxxxx xx xxxxxx xxx xxxxx, xxxxxxx XXX xxxxx xx xxxxxxxxxx xx xxxxxx xxx xxxxxxx xxxxxxxx.¬0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xx xxxxx (xxxxxxxx XXX 1/2 xxxxxxxxxx).¬00 ( 0.0)¬3¬
3¬35¬1¬Xxxxxxxxxxxx XXXXX.¬00 ( 0.0)¬3¬
3¬36¬1¬Xxxxx xxxxxxxxxx xx xxxxxx xxxx xxxxxxxxxxx.¬00 ( 0.0)¬3¬
3¬37¬1¬Xxxxx XXXX X3 xxx Xxxxxx XXXX, XXX xxx XXX XXXXX.¬000 ( 00.0)¬3¬
3¬38¬1¬Xxxx XX xxxxxxxx xxxxxxxxx xxx xxxxx xxxx xxxxx Xxxxxxxxxx'x xxxxxxx (XXxX) >= 470 xx.¬0 ( 0.0)¬3¬
3¬39¬1¬Xxxxxxxx xxxx x xxxxx xxxxxxx xx xxxxxxxxxxxxxxxx xx xxxxxxxxxx xx xxx xx xxx xxxxxxxxxx xx xxx xxxxxxxx.¬0 ( 0.0)¬3¬
3¬40¬1¬Xxx xxxxxxx xxxxxxxxxxxxxxxx xx xxxxxxxxx xxxx xxxxxxxx-xxxxx xxxxxxx xxxxxxxxxxxx.¬0 ( 0.0)¬3¬
3¬41¬1¬Xxxxxxxx xxxxx xxxxxxx xxxxxxx xx xxxxxxxxxx xxxxxxxx xxx xx xxx xxxxxxxxx xxxxxxxxxx: xxxxxxxxxxxxx, xxxxxxxxxxxxxxx, xx xxxxx xxxxxxxxxx.¬0 ( 0.0)¬3¬
3¬42¬1¬Xxx xxxxxxxxxx xxxxxxxxxxxx, XX, xxxxxxxx, xx xxxxxxxx xxxxxxx xxx xxxxxx xxxxxxxxx.¬0 ( 0.0)¬3¬
3¬43¬1¬Xxxxxxxxxxxx xxxxxxxxx xx xxxx xxxx 30% xx xxx xxxx xxxxxx xx xxxx x xxxx xxxxx xx xxxxxxxxx xxxxxx 4 xxxxx xx xxx xxxxx xxxx xx XX.¬0 ( 0.0)¬3¬
3¬44¬1¬Xxxxxxx xx xxxxx xxx xx xxxxxxxxxxxxxxxxx xxxxxxxxxx xxxxxx 14 xxxx xxxxxx xxx xxxxx xxxx xx xxx XX.¬0 ( 0.0)¬3¬
3¬45¬1¬Xxxxxxxx xx xxx Xxxxxxxxxxxx xxxx xxx xxxxxxx xxxxxx xxx xxxxxxxxxxx xx xxx xxxxx xx xxx xxxxxxx xx xxxxxxxx xx xxxxxx xxxx xxxxx xxxxxxxxxx, xxxxxxxxxxxx, xxx xxxxxxxxxxxx.¬00 ( 00.0)¬3¬
3¬46¬1¬Xxxxxxxx xxxx x xxxxxxxxxx xxxx xxxxxx xxxxxxxxxx xxx xxxxxxxx xx xx XXXXx xx XXX xxxxxxxxxxxxx.¬00 ( 0.0)¬3¬Page 3 of 3
;
RUN;
%let border = %str(~S={protectspecialchars=off pretext='\brdrb\brdrs\brdrw1' });
ods escapechar='~';
TITLE1 j=l "Title One";
TITLE4 j=c "Title Two";
ODS listing close;
options orientation=landscape;
ODS RTF file=myfilelc style=mystyle;
PROC REPORT data= have nowindows headline headskip split="#" spacing=1 missing formchar(2) = "__" style(report)={outputwidth=100%};
COLUMN _page ord1 ord2 ord3 col1 ("&border XXXXXX (%) XX XXXXXXXX" col2) _pagev;
DEFINE _page / order noprint;
DEFINE _pagev / order noprint;
DEFINE ord1 / order noprint;
DEFINE ord2 / order noprint;
DEFINE ord3 / order noprint;
DEFINE col1 / "" style=[just=l cellwidth=60% asis=on ] style(header)=[just=l asis=on] flow;
DEFINE col2 / "XXXXXXX" style=[just=l cellwidth=35% asis=on leftmargin=15%] ;
break after _page / page;
compute after ord1;
line "";
endcomp;
compute before _page;
line "";
endcomp;
compute after _page;
line "";
endcomp;;
compute after _page_ / style=[asis=on just=R bordertopcolor=black bordertopwidth=2 bordertopstyle=solid];
line _pagev $;
endcomp;
compute col1;
if ord3=1 THEN call define(_col_, "STYLE", "STYLE=[protectspecialchars=off pretext='\pnhang\fi-110\li330'] ");
endcomp;
RUN;
ODS RTF close;
ODS listing ;
@SwissC wrote:
Hi,
I am having some issues with trying to indent text in an RTF output. Code and input data are available below. If you look at the attached images, the lines starting with a number (ord2 in(5 6 7 8 13) are not displayed correctly.
Does anybody have any idea why this may be? All the other rows are displayed as expected. I do not ever remember coming across this before when I have used identation like in the code below.
You are using a custom ODS style. We may need the definition of that style as that may have an impact.
You posted 3 pages and none of them show an ORD2 value in (5 6 7 8 13) and on which page??? Trying to COUNT lines is hard for someone else's data especially when we don't know which page is involved.
My guess is that the raw rtf codes you are inserting into Col1 are prepended to the value of the col and generate something like
\pnhang\fi-110\li3301
Where the 1 in 3301 is the value of Col1 and is getting used as numeric value with li instruction, yielding li3301 instead of li330 before displaying the 1.
You might try using the Escapechar RAW function instead of literal text there.
I suggest generating ONE example page and do not use NOPRINT for ORD2 so we can actually see. Also include one for what the expected appearance is supposed to be. We have no idea what output you may actually want for those.
@SwissC wrote:
Hi,
I am having some issues with trying to indent text in an RTF output. Code and input data are available below. If you look at the attached images, the lines starting with a number (ord2 in(5 6 7 8 13) are not displayed correctly.
Does anybody have any idea why this may be? All the other rows are displayed as expected. I do not ever remember coming across this before when I have used identation like in the code below.
You are using a custom ODS style. We may need the definition of that style as that may have an impact.
You posted 3 pages and none of them show an ORD2 value in (5 6 7 8 13) and on which page??? Trying to COUNT lines is hard for someone else's data especially when we don't know which page is involved.
My guess is that the raw rtf codes you are inserting into Col1 are prepended to the value of the col and generate something like
\pnhang\fi-110\li3301
Where the 1 in 3301 is the value of Col1 and is getting used as numeric value with li instruction, yielding li3301 instead of li330 before displaying the 1.
You might try using the Escapechar RAW function instead of literal text there.
I suggest generating ONE example page and do not use NOPRINT for ORD2 so we can actually see. Also include one for what the expected appearance is supposed to be. We have no idea what output you may actually want for those.
Thanks Ballardw, that sounds like a possible reason. Will check it out on Monday when I am back in the office.
What do you mean by "Escapechar RAW function"?
@SwissC wrote:
Thanks Ballardw, that sounds like a possible reason. Will check it out on Monday when I am back in the office.
What do you mean by "Escapechar RAW function"?
Look in the documentation under ODS Escapechar. The section labeled "Using the ODS ESCAPECHAR Functions" shows a list of a 20 or so function to do special actions such as display Dagger character, super- and supscript text and so on. One of them is RAW to insert RAW characters used by rendering programs, such as the RTF strings you using.
Note that STYLE is one of those functions.
Hi:
It looks to me like you are not doing a hanging indent inside one cell though. You want your first row to be flush left and then you want all the secondary rows under that first row (indicated by ord3=1) to be indented. It looks like a hanging indent, but I don't think the RTF control strings are needed for the look of the hanging indent because all you want to do is indent when ORD3=1. This is how I show doing an indent for this type of demographic report using either LEFTMARGIN= or INDENT=. I just used STYLE=JOURNAL because that eliminated the interior table lines. I didn't bother with your border because it wasn't relevant to the indent question.
Cynthia
Hi:
In that case, LEFTMARGIN and INDENT work differently if the line is longer, as shown below:
It looks like INDENT= is NOT what you want, because the longer lines go back to the original left margin. On the other hand LEFTMARGIN treats the longer lines differently, as shown above (I modified my original program to make longer lines for some of the ORD3=1 rows.
Cynthia
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.