Hi
Can any one help with following. (value in 'amt' column should be changed i.e, '.' should be replaced by ',')
data have;
name='alpha';amt=100090.23; output;
name='beta';amt=299999.12; output;
run;
data want;
name='alpha';amt='100090,23'; output;
name='beta';amt='299999,12'; output;
run;
Thanks in advance
Add NUMXw.d format . You must come from somewhere of Euro ?
data have;
name='alpha';amt=100090.23; output;
name='beta';amt=299999.12; output;
format amt numx12.2;
run;
Xia Keshan
Please check this:
Thanks, but what I have is a numeric column with a decimal value and translate and tranwrd are useful for character columns.
You want to assign the COMMAX format to this numeric variable.
@PaigeMiller: I just wanted to replace . with , and commax format also inserts period that separates every three digits.
But any ways, I converted the column to char and used translate, it works fine.
Numeric data does not allow commas, slashes, or any other special character other than -0123456789.. If you want to have comma's then you either need to apply a format - such as PaigeMiller has suggested - which basically applies a viewing format to the data which would remain unchanged, or convert the numeric data into a text field and then use textual replace functions on it.
data want;
set have;
length new_amt $20;
new_amt=tranwrd(put(amt,best.),".",",");
run;
Add NUMXw.d format . You must come from somewhere of Euro ?
data have;
name='alpha';amt=100090.23; output;
name='beta';amt=299999.12; output;
format amt numx12.2;
run;
Xia Keshan
Thanks! thats perfect and also correct guess.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.