I used PROC MEANS to obtain a mean and corresponding 95% CI. I need to output this in a table as XX.XX (XX.XX, XX.XX); i.e. mean (95% CI). I am having difficulties getting a consistent two decimal places. The round() and input(strip(), 5.2), but the trailing zeroes disappear.
data have;
input period trt $ mean lb ub @@;
cards;
1 A 33.791 32.700123 32.801568
1 B 34.928 34.275056 35.005235
2 A 31.320 30.567487 31.496871
2 B 30.541 29.654630 31.507468
;
run;
data want;
input period trt $ mean $ lb $ ub $ @@;
cards;
1 A 33.79 32.70 32.80
1 B 34.93 34.28 35.01
2 A 31.32 30.57 31.50
2 B 30.54 29.65 31.51
;
run;
Something like this:
displayValue = catt(PUT(Mean, 8.2),
'(',
put(lb, 8.2),
", ",
put(ub, 8.2),
")"
);
@mariko5797 wrote:
I used PROC MEANS to obtain a mean and corresponding 95% CI. I need to output this in a table as XX.XX (XX.XX, XX.XX); i.e. mean (95% CI). I am having difficulties getting a consistent two decimal places. The round() and input(strip(), 5.2), but the trailing zeroes disappear.
data have; input period trt $ mean lb ub @@; cards; 1 A 33.791 32.700123 32.801568 1 B 34.928 34.275056 35.005235 2 A 31.320 30.567487 31.496871 2 B 30.541 29.654630 31.507468 ; run; data want; input period trt $ mean $ lb $ ub $ @@; cards; 1 A 33.79 32.70 32.80 1 B 34.93 34.28 35.01 2 A 31.32 30.57 31.50 2 B 30.54 29.65 31.51 ; run;
Simply apply an appropriate format
data want;
set have;
format mean lb ub 8.2;
run;
Show the code you use to create that stuff.
Likely you need to specify a format with PUT that uses 2 decimals such as PUT(somevariable, f6.2) which will force two decimals. The format will round the values using typical rounding rules to display the last decimal place.
data have; input period trt $ mean lb ub @@; meanchar = put (mean,5.2); lbchar = put (lb,5.2); ubchar = put (ub,5.2); cards; 1 A 33.791 32.700123 32.801568 1 B 34.928 34.275056 35.005235 2 A 31.320 30.567487 31.496871 2 B 30.541 29.654630 31.507468 ; run;
Something like this:
displayValue = catt(PUT(Mean, 8.2),
'(',
put(lb, 8.2),
", ",
put(ub, 8.2),
")"
);
@mariko5797 wrote:
I used PROC MEANS to obtain a mean and corresponding 95% CI. I need to output this in a table as XX.XX (XX.XX, XX.XX); i.e. mean (95% CI). I am having difficulties getting a consistent two decimal places. The round() and input(strip(), 5.2), but the trailing zeroes disappear.
data have; input period trt $ mean lb ub @@; cards; 1 A 33.791 32.700123 32.801568 1 B 34.928 34.275056 35.005235 2 A 31.320 30.567487 31.496871 2 B 30.541 29.654630 31.507468 ; run; data want; input period trt $ mean $ lb $ ub $ @@; cards; 1 A 33.79 32.70 32.80 1 B 34.93 34.28 35.01 2 A 31.32 30.57 31.50 2 B 30.54 29.65 31.51 ; run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.