The SAS Output Delivery System and reporting techniques

COMPUTE BEFORE _PAGE_ Center and Left Alignment (Justification)

Accepted Solution Solved
Reply
Contributor
Posts: 43
Accepted Solution

COMPUTE BEFORE _PAGE_ Center and Left Alignment (Justification)

[ Edited ]

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


Accepted Solutions
Solution
‎12-18-2017 09:34 AM
Contributor
Posts: 43

Re: COMPUTE BEFORE _PAGE_ Center and Left Alignment (Justification)

Posted in reply to craig159753

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

View solution in original post


All Replies
Super User
Posts: 10,205

Re: COMPUTE BEFORE _PAGE_ Center and Left Alignment (Justification)

Posted in reply to craig159753
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;
Contributor
Posts: 43

Re: COMPUTE BEFORE _PAGE_ Center and Left Alignment (Justification)

Thanks for the response, this left aligns both lines, I just want the last line left aligned.

Super User
Super User
Posts: 8,371

Re: COMPUTE BEFORE _PAGE_ Center and Left Alignment (Justification)

Posted in reply to craig159753

I have nothing to test this on, but what about:

 

    line cats("^S={just=left}",mytextvar);

 

Contributor
Posts: 43

Re: COMPUTE BEFORE _PAGE_ Center and Left Alignment (Justification)

Thanks for the response, this did not work Smiley Sad

Super User
Super User
Posts: 8,371

Re: COMPUTE BEFORE _PAGE_ Center and Left Alignment (Justification)

Posted in reply to craig159753

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.

Solution
‎12-18-2017 09:34 AM
Contributor
Posts: 43

Re: COMPUTE BEFORE _PAGE_ Center and Left Alignment (Justification)

Posted in reply to craig159753

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 219 views
  • 0 likes
  • 3 in conversation