Hi,
I am trying to add some text before a table, using ODS and PROC REPORT and have done this,
define mytextvar / order order=internal noprint;
compute before _page_ / style = {just=center font_weight=bold};
line "My first title which is centered";
line " ";
line @1 mytextvar $200. "^S={just=left}";
endcomp;
However the output is a little odd and my left aligned line is not truly left aligned and looks likes this
| My first tile which is centered |
| |
| My text value from MYTEXTVAR |
| |
Any idea if there is solution or a better way, I want the line "My text value from MYTEXTVAR" to be left aligned, the rest must remain the same.
Please note I cannot use the TITLE statement for this.
Thanks
Craig
FIXED IT!
The solution utilizes RTF code to achieve what I wanted.
For SAS to use RTF code, you first need to tell it you are using RTF code.
^R/RTF - indicates RTF code
\par - new paragraph, i.e. hitting ENTER on a keyboard in word.
\ql - left align.
The final code looked like this
define mytextvar / order order=internal noprint;
compute before _page_ / style = {just=center font_weight=bold};
line "My first title which is centered";
line " ";
line " ^R/RTF'\par\ql '" mytextvar $200.;
endcomp;
The output then looks like this
| My first tile which is centered |
| |
| My text value from MYTEXTVAR |
| |
Thanks
Craig
compute before _page_ / style = {just=center font_weight=bold};
line "^S={just=left} My first title which is centered";
line " ";
line @1 mytextvar $200. ;
endcomp;
Thanks for the response, this left aligns both lines, I just want the last line left aligned.
I have nothing to test this on, but what about:
line cats("^S={just=left}",mytextvar);
Thanks for the response, this did not work 😞
Can I point out a couple of things. Firstly, stating "it did not work" is not helpful, what did not work? Logs?
Secondly, mentioning the whole of the problem is a good starting point, such as you are outputting to RTF. And also posting something which we can actual run and test things also helps.
FIXED IT!
The solution utilizes RTF code to achieve what I wanted.
For SAS to use RTF code, you first need to tell it you are using RTF code.
^R/RTF - indicates RTF code
\par - new paragraph, i.e. hitting ENTER on a keyboard in word.
\ql - left align.
The final code looked like this
define mytextvar / order order=internal noprint;
compute before _page_ / style = {just=center font_weight=bold};
line "My first title which is centered";
line " ";
line " ^R/RTF'\par\ql '" mytextvar $200.;
endcomp;
The output then looks like this
| My first tile which is centered |
| |
| My text value from MYTEXTVAR |
| |
Thanks
Craig
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.