The SAS Output Delivery System and reporting techniques

alignment problem with proc report

Reply
N/A
Posts: 0

alignment problem with proc report

Indicatuib statistic Value
xxxxx N(%) 42 (60.87)
yyyyy N(%) 8 (11.59)
zzzzz N(%) 0
wwww N(%) 19 (27.54)
I have used proc report (ODS RTF) to display above output and used right alignment to display the value column which is concatenated value of count and percent.
but 0 is not aligned properly. I dont want to display percent for zero count. In such a case zero should be displayed just below the count but not below the percent.
help me to solve this problem
SAS Super FREQ
Posts: 8,868

Re: alignment problem with proc report

Posted in reply to deleted_user
Hi:
As far as PROC REPORT is concerned, the 0 is aligned properly -- if 0 is the only value in the cell, and you specify just=r, then the 0 should be right-aligned -- and it sounds like that is what you're seeing -- so you know that justification is working -- just not the way you want.

What you may want to do is "pad" the 0 value with non-breaking spaces so it shifts position from the right border of the cell. Or you may want to find out whether there are any RTF control strings that would let you control alignment. I have an example of the ESCAPECHAR method of padding.

In ODS, a non-breaking space can be inserted into your output by specifying the ODS ESCAPECHAR + underscore. This means if you have this statement in your code:
[pre]
ods escapechar='^';
[/pre]

that ^_ will be treated as a non-breaking space by ODS and sent as such to the destination.

So, assuming you have this data:
[pre]
xxxxx N(%) 42 (60.87)
yyyyy N(%) 8 (11.59)
zzzzz N(%) 0
wwww N(%) 19 (27.54)
[/pre]

in a file called "work.testrept" (in my test, I made the length of Value $30 to hold the ESCAPECHAR string), then this code (below) would "pad" the 0. Note that with different style templates being used, you may or may not need to adjust the number of non-breaking spaces that you have.

cynthia
[pre]

ods listing close;
ods rtf file='c:\temp\padright.rtf' style=journal;

ods escapechar='^';

proc report data=testrept nowd;
column Indicatuib statistic Value;
define Indicatuib / order order=data;
define statistic / display;
define Value / display
style(column)={just=r asis=on};
compute Value;
if Value = '0' then do;
Value = catt(Value,'^_^_^_^_^_^_^_^_^_^_^_^_');
end;
endcomp;
run;
ods rtf close;

[/pre]
N/A
Posts: 0

Re: alignment problem with proc report

Posted in reply to deleted_user
Hi

Thank you! Its working fine.
Ask a Question
Discussion stats
  • 2 replies
  • 157 views
  • 0 likes
  • 2 in conversation