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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

 

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Simply apply an appropriate format

 

data want;
   set have;
   format mean lb ub 8.2;
run;
ballardw
Super User

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;
Reeza
Super User

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;

 

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
  • 1522 views
  • 0 likes
  • 4 in conversation