BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
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]
deleted_user
Not applicable
Hi

Thank you! Its working fine.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1684 views
  • 0 likes
  • 2 in conversation