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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.