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


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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

View solution in original post

7 REPLIES 7
venka
Calcite | Level 5

Thanks, but what I have is a numeric column with a decimal value and translate and tranwrd are useful for character columns.

PaigeMiller
Diamond | Level 26

You want to assign the COMMAX format to this numeric variable.

--
Paige Miller
venka
Calcite | Level 5

@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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

Ksharp
Super User

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

venka
Calcite | Level 5

Thanks! thats perfect and also correct guess.

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2687 views
  • 3 likes
  • 5 in conversation