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
SAS Super FREQ
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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1132 views
  • 0 likes
  • 2 in conversation