convert character variable to numeric

Reply
Occasional Contributor
Posts: 13

convert character variable to numeric

Hi all if a variable is of character type and having numeric values then how to convert it to numeric.

Respected Advisor
Posts: 3,894

Re: convert character variable to numeric

Use the input() function with an appropriate informat, eg. Numvar=input(charvar,20.);

Occasional Contributor
Posts: 13

Re: convert character variable to numeric

thanks patrick

Super Contributor
Posts: 1,636

Re: convert character variable to numeric

data have;

input a$ @@;

cards;

1 2 3

;

data want;

  set have;

  b=input(a,best12.);

run;

proc contents data=want;run;

Ask a Question
Discussion stats
  • 3 replies
  • 363 views
  • 2 likes
  • 3 in conversation