Conversion of character to numeric variable in SAS

Accepted Solution Solved
Reply
New Contributor oab
New Contributor
Posts: 4
Accepted Solution

Conversion of character to numeric variable in SAS

I am trying to convert a character variable to numeric

 

I have a column of data with the following attributes:

 

Data Set Name: woleaim1

Variable: age

Type: Char

Len: 3

Format: $3.

Informat: $3.

 

These data are formatted as character and I want to convert it to numeric. I tried the following command 

 

data woleaim1;
age_num = input(age, $3.);
run;

 

This is the error message below:

 

NOTE: Numeric values have been converted to character values at the places given by: (Line)Smiley SadColumn).
588:23
NOTE: Variable age is uninitialized.
NOTE: The data set WORK.WOLEAIM1 has 1 observations and 2 variables.
 
Thanks!


Accepted Solutions
Solution
‎04-27-2018 12:58 AM
PROC Star
Posts: 1,784

Re: Conversion of character to numeric variable in SAS

data have;
input age $;
cards;
12
15
43
;

data want;
set have ;
newage=input(age,8.);
run;

View solution in original post


All Replies
Solution
‎04-27-2018 12:58 AM
PROC Star
Posts: 1,784

Re: Conversion of character to numeric variable in SAS

data have;
input age $;
cards;
12
15
43
;

data want;
set have ;
newage=input(age,8.);
run;
New Contributor oab
New Contributor
Posts: 4

Re: Conversion of character to numeric variable in SAS

Posted in reply to novinosrin
Thank you. It worked!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 131 views
  • 1 like
  • 2 in conversation