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.
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 lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.