BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASGeek
Quartz | Level 8

Hi there, 

I'm wondering if what I want to do in ODS with PROC REPORT is possible. Currently the following code works but as expected -- the % Yes column header spans the two columns, but one row higher than I want it to. Any way to work around that?

 

Thanks

 

data uc1;
INPUT DIVISION $  No       pct_n_total  Yes    pct_y_total;
LENGTH DIVISION  $ 1 No 8 pct_n_total 8 Yes 8 pct_y_total  8;
FORMAT
DIVISION         $CHAR1.
No               COMMA12.2
pct_n_total      COMMA12.2
Yes              COMMA12.2
pct_y_total      COMMA12.2;
datalines;
a 79354 0.4685 90034 0.5315
b 94541 0.6260 56479 0.3740
c 10635 0.1183 79255 0.8817
d 40340 0.4720 45118 0.5280
;
run;
 
ods pdf file = "/home/zkurzej/file.pdf" style=smaller  STARTPAGE=NEVER;
footnote j=c "Page ^{thispage} of ^{lastpage}";
ods layout absolute;
ods region x=0.00in y=.75in width=3.38in height=6.8in;
 
proc report data= uc1 nowd missing split= '~' 
style(report) = [cellspacing = 2 cellpadding =4 rules=groups frame=hsides]
style(header) = [fontsize=6pt vjust = top]
style(column)=[fontsize=6pt];
Title "uc1";
column DIVISION
No
pct_n_total
Yes
('% Yes' pct_y_total bar);
define DIVISION / 'DIVISION';
define No / 'No' format = comma15.0;
define pct_n_total / '% No' format = percent10.2;
define Yes / '% Yes' format = comma15.0;
define pct_y_total / '% Yes' format = percent10.2
style(column) = [borderrightcolor=black borderrightwidth=.5pt];
define bar / ' '  style(column) = [font_size=4pt
fontfamily='Courier New' 
vjust=middle 
just=left cellpadding=0];
 
compute bar / char length = 1000;
barsize = round(pct_y_total.sum*50);
if barsize gt 0 then
do;
bar = repeat('^{unicode 2588}', barsize);
call define ('_c6_','style','style={foreground = red}');
end;
endcomp;
run;
 
ods layout end;
ods pdf close;
 
example.png
1 ACCEPTED SOLUTION

Accepted Solutions
ahmedalattar
Fluorite | Level 6

@SASGeek

Try changing the column statement to this 

column ('DIVISION' DIVISION) ('No' No) ('% No' pct_n_total) ('Yes' Yes) ('% Yes' pct_y_total bar);

Replace the columns labels with '' (missing) in the define statements, such as

define DIVISION / '' ;
define No / '' format = comma15.0;
define pct_n_total / '' format = percent7.3;
define Yes / '' format = comma15.0;
define pct_y_total / '' format = percent7.3
style(column) = [borderrightcolor=black borderrightwidth=.5pt];

define bar / '' style(column) = [font_size=4pt
fontfamily='Courier New' 
vjust=middle 
just=left cellpadding=0];

This should give you what you are looking for

 

View solution in original post

3 REPLIES 3
ahmedalattar
Fluorite | Level 6

@SASGeek

Try changing the column statement to this 

column ('DIVISION' DIVISION) ('No' No) ('% No' pct_n_total) ('Yes' Yes) ('% Yes' pct_y_total bar);

Replace the columns labels with '' (missing) in the define statements, such as

define DIVISION / '' ;
define No / '' format = comma15.0;
define pct_n_total / '' format = percent7.3;
define Yes / '' format = comma15.0;
define pct_y_total / '' format = percent7.3
style(column) = [borderrightcolor=black borderrightwidth=.5pt];

define bar / '' style(column) = [font_size=4pt
fontfamily='Courier New' 
vjust=middle 
just=left cellpadding=0];

This should give you what you are looking for

 

SASGeek
Quartz | Level 8
Good idea. Thanks. I'll give it a try!

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch 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
  • 609 views
  • 4 likes
  • 3 in conversation