From: josemanuel on
Hello,

In the process of generating a series of tables with PROC REPORT and
ODS RTF, I'd like to create a large text field containing some
standard text interspersed with some values from datasets. The
resulting single-cell table would look something like this:

"First, I went to the VARIABLE1, and afterwards, I went to the
VARIABLE2. I decided to finish the day with VARIABLE3 instead of
going all the way to VARIABLE4 or VARIABLE5."

The desired length of the text stream should be arbitrary (perhaps
around 1000 - 2000 characters).

It would be best (for me) if someone knew of a way to write this like
the following:

data test;
format testvar $1000.;
testvar="First, I went to the " || VARIABLE1 || ", and afterwards, I
went to the " || VARIABLE2 || ". I decided to finish the day with "
|| VARIABLE3 || "instead of going all the way to " || VARIABLE4 || "
or " || VARIABLE5 || "."
run;

proc report data=test;
column (testvar);
define testvar/display;
run;

Of course, if testvar >256 characters, it will be truncated. I'd be
satisfied if I could print the desired text in PROC PRINT even. Is
anyone aware of a potential solution?

Thanks very much,

Chris

From: Lou on

"josemanuel" <cmgast(a)gmail.com> wrote in message
news:135b8d65-89ec-4e09-8c59-00148b2479e3(a)11g2000prw.googlegroups.com...
> Hello,
>
> In the process of generating a series of tables with PROC REPORT and
> ODS RTF, I'd like to create a large text field containing some
> standard text interspersed with some values from datasets. The
> resulting single-cell table would look something like this:
>
> "First, I went to the VARIABLE1, and afterwards, I went to the
> VARIABLE2. I decided to finish the day with VARIABLE3 instead of
> going all the way to VARIABLE4 or VARIABLE5."
>
> The desired length of the text stream should be arbitrary (perhaps
> around 1000 - 2000 characters).
>
> It would be best (for me) if someone knew of a way to write this like
> the following:
>
> data test;
> format testvar $1000.;
> testvar="First, I went to the " || VARIABLE1 || ", and afterwards, I
> went to the " || VARIABLE2 || ". I decided to finish the day with "
> || VARIABLE3 || "instead of going all the way to " || VARIABLE4 || "
> or " || VARIABLE5 || "."
> run;
>
> proc report data=test;
> column (testvar);
> define testvar/display;
> run;
>
> Of course, if testvar >256 characters, it will be truncated. I'd be
> satisfied if I could print the desired text in PROC PRINT even. Is
> anyone aware of a potential solution?
>
First, you probably want your code to read something like

testvar="First, I went to the " || trim(VARIABLE1) ||", and afterwards...

TESTVAR can be as long as you like, up to the SAS limit on character
variables of 32,767 characters. PROC REPORT has no problem displaying the
full text of long character variables - to do so, your DEFINE statement
would be something like

DEFINE TESTVAR / DISPLAY FORMAT = $32767. WIDTH = 50 FLOW;

If your output is to the ODS RTF destination, use the appropriate STYLE
statements to control the column width.

To get a truncated version in PROC PRINT, use a shorter format
specification.