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

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

1 ACCEPTED SOLUTION

Accepted Solutions
craig159753
Quartz | Level 8

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

6 REPLIES 6
Ksharp
Super User
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;
craig159753
Quartz | Level 8

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

 

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

 

craig159753
Quartz | Level 8

Thanks for the response, this did not work 😞

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

craig159753
Quartz | Level 8

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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