Help using Base SAS procedures

Character Data vs Numeric

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Character Data vs Numeric

How do you convert character data to numeric?


Accepted Solutions
Solution
‎08-04-2011 06:30 PM
PROC Star
Posts: 7,492

Character Data vs Numeric

Best12. is simply a SAS numeric format.  The only place the $ was relevant was in reading the original values as characters.  Thus, in the example, have already is in character format and that was only used to create an example file.

In datastep want, the numeric variable want was created by re-inputting the variable have by converting it with the input function.

View solution in original post


All Replies
PROC Star
Posts: 7,492

Character Data vs Numeric

data have;

  input have $;

cards;

1

10

333

;

data want;

  set have;

  want=input(have,best12.);

run;

New Contributor
Posts: 3

Character Data vs Numeric

I think I understand.  What does "best12." refer to?  It looks like I need to insert the $ symbol immediately after the charcter in the input statement.

Solution
‎08-04-2011 06:30 PM
PROC Star
Posts: 7,492

Character Data vs Numeric

Best12. is simply a SAS numeric format.  The only place the $ was relevant was in reading the original values as characters.  Thus, in the example, have already is in character format and that was only used to create an example file.

In datastep want, the numeric variable want was created by re-inputting the variable have by converting it with the input function.

New Contributor
Posts: 3

Character Data vs Numeric

Thanks for the help.

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 184 views
  • 3 likes
  • 2 in conversation