BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dinkepile
Obsidian | Level 7

Good day

 

I am trying to align my values of the circled column on the picture below, please advise. I have attached an example of an output with proper aligned values.  I have also attached a code to be used as an example to use: 

data class;

set sashelp.class;

height = height+.8;

weight = weight+.9;

if name in('Alfred' 'Carol' 'James')

then do;

height = 88.88;

weight =77.77;

end;

if age=14 then count_percent=strip(put(height,6.))||'(12.13)';
else if age=13 then count_percent=strip(put(height,6.))||'(89.3)';
else count_percent=strip(put(height,6.))||'(100.00)';

run;

 

ods listing close;

title; footnote;

ods tagsets.RTF file='C:\Users\just_d.rtf';

 

proc report data=class nowd headline headskip split='~' missing style ( report )=[frame=hsides outputwidth = 10in background = white
font_face='Courier New' font_size=3]
style(column)={just=CENTER font_face='Courier New' background=white foreground=black
font_size=3 cellwidth=.6in}
style(header)={just=center font_face='Courier New' cellheight=.8in font_size=3
foreground=black cellwidth=.6in
background=white font_style=roman vjust=t} ;

column name age height weight weight=wt2 count_percent;

define height / 'ht Just=c'

style(column)={just=c};

define weight / 'wt just=d'

style(column)={just=d};

define wt2 / 'wt just=d/chg margin'

style(column)={just=d width=1.0in rightmargin=.25in};

define count_percent / 'wt just=d/chg margin'

style(column)={just=d width=1.0in rightmargin=.25in};

run;

ods _all_ close;

 

Dinkepile_0-1613479519431.png

on the final report or output i wish the values to align like the example below:

Dinkepile_1-1613479609315.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
proc freq data=sashelp.heart noprint;
table Smoking_Status/out=temp;
run;
data want;
 set temp;
 length c_count $ 8 c_per $ 5;
 c_count=put(count, 8.  -r);
 c_per=put(percent, 4.1 -r);
 value=c_count||'   ('||c_per||')';
 if not missing(Smoking_Status);
run;
ods rtf file='c:\temp\x.rtf';
proc report data=want nowd style(report)={ outputwidth=100%};
define value/display style={just=right font_face=arial};
run;
ods rtf close;

View solution in original post

4 REPLIES 4
Ksharp
Super User
proc freq data=sashelp.heart noprint;
table Smoking_Status/out=temp;
run;
data want;
 set temp;
 length c_count $ 8 c_per $ 5;
 c_count=put(count, 8.  -r);
 c_per=put(percent, 4.1 -r);
 value=c_count||'   ('||c_per||')';
 if not missing(Smoking_Status);
run;
ods rtf file='c:\temp\x.rtf';
proc report data=want nowd style(report)={ outputwidth=100%};
define value/display style={just=right font_face=arial};
run;
ods rtf close;
Dinkepile
Obsidian | Level 7
Good day

Thanks so much for the feedback.

It seem to work but it is not aligning proper where percent is 100. May in
your example if you can include a single observation which has percent
value 100 and see if the values in brackets will align proper?

Kind Regards
Dinkepile
Ksharp
Super User
Just try make cell width bigger.

c_per=put(percent, 4.1 -r);
-->
c_per=put(percent, 5.1 -r);
Dinkepile
Obsidian | Level 7
Thanks so much for your input.

Kind Regards
Dinkepile
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
  • 4 replies
  • 8172 views
  • 0 likes
  • 2 in conversation