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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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