DATA Step, Macro, Functions and more

Table - convert from character to numeric

Accepted Solution Solved
Reply
Occasional Contributor lca
Occasional Contributor
Posts: 10
Accepted Solution

Table - convert from character to numeric

Hi!

I have a table where one one of the columns have character format.

How do I convert the values from character to numeric format with proc sql? Possible?

lca


Accepted Solutions
Solution
‎10-11-2011 11:20 AM
PROC Star
Posts: 7,487

Table - convert from character to numeric

Is this what you are looking for?

data have;

  informat x $2.;

  input x;

  cards;

1

2

3

;

proc sql noprint;

  create table want as

    select input(x,2.) as x

      from have

;

quit;

View solution in original post


All Replies
Solution
‎10-11-2011 11:20 AM
PROC Star
Posts: 7,487

Table - convert from character to numeric

Is this what you are looking for?

data have;

  informat x $2.;

  input x;

  cards;

1

2

3

;

proc sql noprint;

  create table want as

    select input(x,2.) as x

      from have

;

quit;

New Contributor
Posts: 2

Table - convert from character to numeric

I think you meant tthis code:

data have;

  informat x $2.;

  input x;

  cards;

1

2

3

;

proc sql noprint;

  create table want as

    select input(x,$2.) as x

      from have

;

quit;

Occasional Contributor lca
Occasional Contributor
Posts: 10

Table - convert from character to numeric

Yes. Worked. Thank you Smiley Happy

PROC Star
Posts: 7,487

Table - convert from character to numeric

chimanbj1 wrote: I think you meant tthis code: <snip>

No, I meant the code that I posted.  The OP wanted to convert character to numeric.

New Contributor
Posts: 2

Table - convert from character to numeric

You are so right, Art! My mistake!

🔒 This topic is solved and locked.

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

Discussion stats
  • 5 replies
  • 30254 views
  • 0 likes
  • 3 in conversation