BookmarkSubscribeRSS Feed
daveconifer
Calcite | Level 5
Greetings.

I'm trying to use column headers like "++", "+++", "++++" in a shift table that I'm generating with proc report. When I specify this in the DEFINE statement, I get a row of plus signs across the entire column rather than the number of plus signs I specified between the quotes.

When I substitute just about any other character for the plus signs:

define cell4p / width = 12 " aaa~___";
define cell5p / width = 12 " +++~___";


I get exactly what is between the quotes.


WEEK 26
---------------------------------------------
(BASELINE aaa ++++++++++
WEEK -4) ____________ ____________

NEGATIVE 8 ( 1.7) 12 ( 2.5)
TRACE 1 ( 3.3) 0
1+ 3 ( 20.0) 0
2+ 0 1 ( 14.3)
3+ 0 0
4+ 0 0
TOTAL 12 ( 2.3) 13 ( 2.5)

So how do I tell PROC REPORT that there's nothing magical about the plus signs and that I want exactly that number of them and no more?

Thanks!

...dave
9 REPLIES 9
Tim_SAS
Barite | Level 11
This is the expected behavior. See http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473625.htm.
[pre]
In traditional (monospace) SAS output, if the first and last characters of a heading
are one of the following characters, then PROC REPORT uses that character to
expand the heading to fill the space over the column or columns. Note that the <>
and the >< must be paired.

- = . _ * + <> ><

Similarly, if the first character of a heading is < and the last character is >, or
vice versa, then PROC REPORT expands the heading to fill the space over the column
by repeating the first character before the text of the heading and the last character
after it.
[/pre]
This behavior only occurs for listing output, so you can avoid it by writing the report to a non-listing destination such as PDF or HTML. If you must use listing output, you can defeat it by putting a blank before and a blank after the header, so instead of "++HEADER++" use " ++HEADER++ ".

To be completely accurate, when you're writing to a non-listing destination PROC REPORT removes the repeating characters from the header. To retain the plus signs, add an extra blank before and after the header as above. Message was edited by: Tim@SAS
daveconifer
Calcite | Level 5
Hi Tim,

Thanks for replying.

I altered my DEFINE statement to:

define cell5p / width = 12 " +++ ";

(with a leading a trailing space) and I'm still getting the plus signs all the way across the column. Unfortunately I can't output to any other format except the regular listing because this output feeds into an existing document management system.

I was hoping that there was some kind of FORMCHAR statement by which I could remove the "+" from any special treatment, but of course if there was such a solution you'd have mentioned it.

I guess I'm out of luck. Maybe they'll have to go with the plan B I suggested -- altering the heading text!

edit: I've read that over and over now that you pointed it out. It should work, dadgummit...

...dave Message was edited by: daveconifer
daveconifer
Calcite | Level 5
It works if I insert a "z" (or any character, I'd presume) as the first and last character. Just not a blank...
Tim_SAS
Barite | Level 11
Ah, you're right. For listing output, PROC REPORT removes leading and trailing blanks before it looks for expanding characters.

I should've double-checked before I posted. I'm sorry.
daveconifer
Calcite | Level 5
Thanks Tim.

My bosses insist that I use PROC REPORT and now I've checked with a real SAS guy. They have no choice but to change the column headers now. I'm off the hook!

...dave
ballardw
Super User
If a blank to start/end the string may not work try a null charcter. In Windows at least, hold down the Alt key and press 255 on the numeric key pad. It looks like a blank when printed but doesn't normally get stripped in other places, so may not in this case as well.
daveconifer
Calcite | Level 5
Thanks, BallardW. I guess that doesn't fly on a UNIX. I tried it though, and I thank you for the idea...
daveconifer
Calcite | Level 5
Hey Everybody,

Just an update. I was able to achieve my objective using proc report. Instead of embedding the plus signs in column labels I inserted a "compute before _page_" block and printed the column headers exactly as I wanted them.

Thanks for all your help!

...dave
Ksharp
Super User
Hi.you can use ' line ' statement with noheader option to get that.
But I also find another solution ,You can add a variable before this variable to hold prefix
and add another variable after this variable to hold postfix .
but this solution is only suited for the length of label greater than the length of variable .

[pre]
proc report data=sashelp.class nowd;
column prefix name postfix sex;
define prefix /computed format=$1. '_';
define name /display 'Student Name' spacing=0 width=12;
define postfix /computed format=$1. '_' spacing=0;
define sex/'Sex';
run;
[/pre]


Ksharp

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 9 replies
  • 4289 views
  • 0 likes
  • 4 in conversation