BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
PaulN
Obsidian | Level 7

I want to change a character variable to a numeric variable.  The column name is VALUE (length=8, type=char, format=$8., informat=$8.) and the character values in the VALUE column look like this:

 

VALUE

-2,88

2,68

-6,22

-4,57

5,42

and so on

 

I know that I should use the input function and I want to change the commas to decimals points.  Data is coming from Europe so it's using the comma instead of a decimal point.

  

num_value=input(value,????);

 

Any help is appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Something like

 

data have;
input VALUE $;
datalines;
-2,88 
2,68  
-6,22 
-4,57 
5,42  
;

data want;
   set have;
   numval = input(value, commax8.2);
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Something like

 

data have;
input VALUE $;
datalines;
-2,88 
2,68  
-6,22 
-4,57 
5,42  
;

data want;
   set have;
   numval = input(value, commax8.2);
run;
Astounding
PROC Star

Depending on what your data might contain, a slight change could be in order.  Compare these results:

data have;
input VALUE $;
datalines;
-28 
2,68  
-6,22 
-4,57 
5  
;

data want;
   set have;
   numval1 = input(value, commax8.2);
   numval2 = input(value, commax8.);
run;

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 2 replies
  • 394 views
  • 1 like
  • 3 in conversation