## combining two variables

Solved
Occasional Contributor
Posts: 13

# combining two variables

 my variable Mean Std .±. 69.7454545 7.56262296 69.75±7.56 68.0612245 8.51079746

Hi I want to combine Mean and std deviation as Mean ± Std .And I am doing this by using below code.But you can see My variable column it is not correct result.Can any one tell me why it is happening.

data average2;

my variable=compress(round(mean,0.01)||'±'||round(std,0.01));

set average1;run;

Accepted Solutions
Solution
‎04-26-2012 04:20 AM
Super Contributor
Posts: 350

## Re: combining two variables

Hi Kumar,

Try this code..you results will come correct...You are combining mean and std before set statement.

data average2;

set average1;

myvariable=compress(round(mean,0.01)||'±'||round(std,0.01));

run;

Thanks,

Shiva

All Replies
Posts: 4,736

## Re: combining two variables

length my_variable \$20;

my_variable=cats(round(mean,0.01),'±',round(std,0.01));

Solution
‎04-26-2012 04:20 AM
Super Contributor
Posts: 350

## Re: combining two variables

Hi Kumar,

Try this code..you results will come correct...You are combining mean and std before set statement.

data average2;

set average1;

myvariable=compress(round(mean,0.01)||'±'||round(std,0.01));

run;

Thanks,

Shiva

Posts: 1,147

## Re: combining two variables

Hi Kumar,

you can use catx() to solve your problem. Please check the below code. hope it helps.

data concat;

input mean std;

myvariable=catx('±',mean,std);

cards;

69.7454545    7.56262296

68.0612245    8.51079746

;

run;

Output of myvariable:

69.7454545 ± 7.56262296

68.0612245 ± 8.51079746

Thanks,
Jag
Occasional Contributor
Posts: 13