BookmarkSubscribeRSS Feed
1162
Calcite | Level 5
I am trying to create a report from a questionnaire. I'd like to put the question first, followed by each answer and the number and percent for each answer. The table should look something like this:

[pre]
What state did you live in when you went to high school?

Alabama 5 10%
New York 10 20%
California 35 70%
[/pre]

My problem is this. Some of the questions are very long (up to 700 characters). I can't seem to figure out a way to print such long questions. The line statement in the report procedure seems to be limited to 256 characters. I'm trying to use standard text output that I will put into MS Word format, but I'm open to other solutions.

Any suggestions?
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
Hi:
ODS RTF writes Rich Text Format command strings that can be rendered by Microsoft Word (since Microsoft wrote the RTF specifications).

You might consider using ODS to create your file. I would probably use PROC REPORT with a COMPUTE BEFORE the question number variable in order to write the long question text with a LINE statement.

I can imagine providing the long question text in a variety of ways -- either with a user defined format, with Macro variables or just as a big character variable that is in the COLUMN statement, but is a NOPRINT variable (so you can use it in the LINE statement, but not display it on every report row).

There are probably other ways to approach this problem, but I think the key to them all is to use ODS RTF directly, instead of the LISTING destination. That's because ODS destinations (HTML, RTF, PDF) do not have the 256 linesize limitation that the LISTING destination has.

If you are not familiar with PROC REPORT or with ODS, you might consider contacting Tech Support for more help with your particular report needs.
cynthia
1162
Calcite | Level 5
Thanks.

I was using proc report with the line statement, but I was writing the file using proc printto which I now think is the cause of my truncated question as you mentioned. I switched to ODS HTML and got much better results.
Cynthia_sas
Diamond | Level 26
Hi:
That's good. Glad it worked out.
cynthia

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2145 views
  • 0 likes
  • 2 in conversation